posts_per_page overwrites year, month, day
-
Hello,
In a loop, I’m getting all the posts from yesterday.
What I want is to overwrite the maximum posts_per_page setting from the wordpress menu, by setting it to “-1”. But it seems like this does overwrite the arguments “year”, “month”, “day” then, as I get all posts (not only yesterday’s posts) then.
What can I do to get ALL posts from yesterday, but no other posts?
$day = getdate( strtotime('-1 day', strtotime("12:00:00") ) ); $title_args = array( 'post_type' => 'events', 'posts_per_page' => -1, 'year' => $day["year"], 'monthnum' => $day["month"], 'day' => $day["mday"], ); $title_query = new WP_Query($title_args); if ( $title_query->have_posts() ): while( $title_query->have_posts() ): $title_query->the_post(); echo the_title(); endwhile; wp_reset_postdata(); endif;
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘posts_per_page overwrites year, month, day’ is closed to new replies.