WordPress.org

Forums

Querying most commented in the last week (2 posts)

  1. sh3nka7a
    Member
    Posted 1 year ago #

    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

  2. Tara
    Volunteer Moderator
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.