WordPress posts_per_page being ignored?
-
I manage a news site that has several transients set on the home page for different content areas. This has been working well for us, but recently (since our update to PHP7 and WP5 in December), at least twice a day, the posts_per_page argument seems to be ignored, and 10 items are returned. Deleting the transients associated with those queries seems to fix the issue.
Anybody have any idea what this could be? I can’t find any obvious errors when this happens; it just returns ten results instead of what we ask. We don’t use sticky_posts. Here’s a sample:
<?php // Commentary if( false === ( $commentary_query = get_transient( 'commentary_query' ) ) ) { $commentary_query = new WP_Query( [ 'no_found_rows'=>true, 'cat'=>'29','post_type' => 'post', 'post_status'=>'publish','posts_per_page'=>4 ] ); set_transient( 'commentary_query', $commentary_query, 60*60*4 ); } while ( $commentary_query->have_posts() ) : $commentary_query->the_post(); echo '<li><a href="' .get_permalink().'"><h4>' . get_the_title() . '</h4><span class="excerpt">' .get_the_excerpt().'</span></a></li>'; endwhile; wp_reset_postdata(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘WordPress posts_per_page being ignored?’ is closed to new replies.