WordPress.org

Support

Support » Plugins and Hacks » Hacks » Querying most commented in the last week

Querying most commented in the last week

  • Hello, im trying to show the most commented 5 post in the last week, here is my code
    $args = array(
    ‘post_type’ => ‘post’,
    ‘post_status’ => ‘publish’,
    ‘orderby’ => ‘comment_count’,

    ‘order’ => ‘DESC’,
    ‘date_query’ => array(
    array(
    ‘year’ => date(‘Y’),
    ‘week’ => date(‘W’),
    ),
    ),
    ‘posts_per_page’=> 5,
    );

    $the_query = new WP_Query($args);

    while ( $the_query->have_posts()) : $the_query->the_post(); ?>
    That returns me over 300 posts, tho they are ordered by comment cound, how to fix that

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Querying most commented in the last week’ is closed to new replies.
Skip to toolbar