• Resolved briancostea

    (@briancostea)


    I am trying to allow a user to sort the posts on the archive.php file by most commented or most recent. If I change the archive.php page to include this code based a querystring parameter, it doesn’t respect the month and year in the URL; it just displays all posts.

    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    $args= array(
    ‘orderby’ => ‘comment_count’,
    ‘order’ => ‘DESC’,
    ‘paged’ => $paged
    );
    query_posts($args);

    Is there a way for me to grab the month and year out of the URL so that I can display just the posts for that month and year? If so, I can add it to the arguments in the $args array.

    PS — I am using the out of the box archive widget to get to the site.com/year/month page (which displays the archive.php from the site theme).

Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Sort items in archive.php’ is closed to new replies.