Support » Fixing WordPress » single_cat_title() wont work when using comment_count

  • Hi,

    i edit archive.php so it sorts posts by comment count in certain categories. However, by doing this neither single_cat_title() or category_description() show the category name/description. Why is that? This is my code:

    <?php if(is_category( array(25))) { query_posts(array('orderby' => 'comment_count')); } elseif(is_category( array(96))) { query_posts(array('orderby' => 'comment_count', 'posts_per_page' => '20')); } ?>

    This goes to the very beginning of archive.php.

    Could you please give me a hand here?

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    your custom query seems to ‘destroy’ the category archive information.


    <?php global $wp_query; if(is_category( array(25))) { $args = array_merge( $wp_query->query, array( 'orderby' => 'comment_count' ) ); query_posts( $args ); } elseif(is_category( array(96))) { $args = array_merge( $wp_query->query, array( 'orderby' => 'comment_count', 'posts_per_page' => '20') ); query_posts( $args ); } ?>


    thank you but it didnt work. The name and the description do appear now but the posts are not arranged by comment count. I put the code right after <?php if (have_posts()) : ?> should i put it somewhere else?

    Thank you.



    Forum Moderator

    the location seems ok;
    also, in my testsite, the code does what it is supposed to do

    – a possible reason that it is not working for you, might be some interference with other codes or plugins;

    have you tried to deactivate all plugins to see if that helps?

    I think it may be the GD Star rating plugin but i cant try deactivating it because it will delete all my settings.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘single_cat_title() wont work when using comment_count’ is closed to new replies.