Where to add offset?
<?php $recent = new WP_Query( array( ‘tag’ => get_option(‘gd_slider_tags’), ‘posts_per_page’ => get_option(‘gd_slider_num’), ‘offset’ => 1) ); while($recent->have_posts()) : $recent->the_post();?>
<?php $recent = new WP_Query( array( ‘tag’ => get_option(‘gd_slider_tags’), ‘posts_per_page’ => get_option(‘gd_slider_num’), ‘offset’ => 1) ); while($recent->have_posts()) : $recent->the_post();?>
You must ensure that the post type is registered with has_archive property set to true Look at codex example, replace ‘Books’ with ‘Products’ function codex_custom_init() { $labels = array( ‘name’ => ‘Books’, ‘singular_name’ => ‘Book’, ‘add_new’ => ‘Add New’, ‘add_new_item’ => ‘Add New Book’, ‘edit_item’ => ‘Edit Book’, ‘new_item’ => ‘New Book’, ‘all_items’ => ‘All … Read more
It looks OK to me. There is nothing wrong with this part of your code. Maybe some earlier part is doing something strange with your $wp_query variable. You can try to add rewind_posts() before your loop – it should help. Just place rewind_posts(); just before if (have_posts())….
The next_post_link() and previous_post_link() functions do not use the same query that ‘pre_get_posts’ affects. They use their own custom queries. You have to use other filters to affect them. Utimately, the get_adjacent_post() function does the bulk of the work for the next_post_link() and previous_post_link() functions. Here is part of that function: $adjacent = $previous ? … Read more
try this <div class=”container”> <div class=”inner_box”> <ul> <?php while ( have_posts() ) : the_post(); ?> <li> <?php the_title(); ?> <?php the_content(); //this is not in inner_box ?> </li> <?php endwhile; ?> </ul> </div> </div> try this <div class=”container”> <ul> <?php while ( have_posts() ) : the_post(); ?> <li> <div class=”inner_box”> <?php the_title(); ?> <?php the_content(); … Read more
According to your question: What is the main reason of loop? the clearest answer comes from official documentation: The Loop is PHP code used by WordPress to display posts. Using The Loop, WordPress processes each post to be displayed on the current page, and formats it according to how it matches specified criteria within The … Read more
I couldn’t understand your question. exactly Do you want next, prev post pagination? or You want to see next and prev posts titles or other content? Actually you placed an incorrect value to offset. You have to do something like this. // Initialize where to start the post from, 0 is most recent post $init_count … Read more
Figured it out, but not sure if it’s the best way or not. I got the id of the current post in the loop and then used is_single to figure out which post was being displayed, then gave if the styling. The problem was, this was also carrying over to the next itteration of the … Read more
Inside a template file, the standard loop syntax will display only the information about that page( In fact, a template file is no more than a page ). If you want to display some posts you need to run a custom query or to include ( get_template_part() ) another template file which normally runs a … Read more
NVM y’all I fixed my problem on my own! For those of you interested in how I fixed it – it had nothing to do with needing to use pre_get_posts! All it boiled down to was that I needed to go into the wp-admin page (the wordpress dashboard) and go to Settings then Reading and … Read more