WordPress.org

Support

Support » Themes and Templates » Multiple queries – limit one of them to last X days

Multiple queries – limit one of them to last X days

  • Google and also checked it a lot in forums. The suggested solution that i found using posts_where filter does not work fine when using multiple queries on page (or i just couldn’t use it correct).

    I do have around 10 different query on front page as below

    <?php
    $args = array(
      'posts_per_page' => 2,
      'cat' => 99
    );
    $wp_query = new WP_Query();$wp_query->query($args);
    while ($wp_query->have_posts()) : $wp_query->the_post();	
    
    // query content
    
    $count++; endwhile; wp_reset_query();
    ?>

    The requirement is to have only one of those loops to query posts published within X last days. How the code above needs to be modified to be able to handle that?

    Any help is greatly appreciated.

  • The topic ‘Multiple queries – limit one of them to last X days’ is closed to new replies.