Posts per page missing 2 posts – Custom query
-
I am running a custom query but when returning posts_per_page, it is always two behind. I am using a custom post type called events, that is pulling in the code to display the posts from the functions file. I also want to implement pagination, will this be a problem?
Any ideas?
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //Current exhibitions $args = array( 'post_type' => 'exhibitions', 'orderby' => 'exhibition_start_date', 'meta_key' => 'exhibition_start_date', 'order' => 'ASC', 'posts_per_page' => 6, 'paged' => $paged ); $my_query = new WP_Query( $args ); while ( $my_query->have_posts() ) : $my_query->the_post(); $exhibition_start_date = get_post_meta($post->ID, 'exhibition_start_date', true); //Current if ($exhibition_start_date >= date('Y-m-d') ) { get_exhibition_container(); } endwhile; wp_reset_postdata(); ?>
I can post the custom function from my functions file if need be but it’s quite long
Would there be any reason for it consistensly missing two posts?
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Posts per page missing 2 posts – Custom query’ is closed to new replies.