WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] orderby comment_count being ignored

[Resolved] orderby comment_count being ignored

  • I’m trying to loop through the 4 most commented posts with the following code:-

    <?php	$mcQuery = new WP_Query ( array ('orderby' => 'comment_count', 'order' => 'DESC', 'posts_per_page' => '4' ) );
    		if ( $mcQuery->have_posts ()) :
    			while ( $mcQuery->have_posts () ) :
    				$mcQuery->the_post (); ?>

    Stuff……..

    <?php			endwhile;
                     endif;
    		 wp_reset_postdata (); ?>

    All I get back is the 4 most recent posts, posts_per_page working as expected but not the orderby.

    Anyone have any suggestions as to what is happening or spot anything I am doing wrong?

Viewing 1 replies (of 1 total)
  • Problem found.

    The pluggin WP-Sticky was breaking things, it was high-jacking the query but not carrying through orderby.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] orderby comment_count being ignored’ is closed to new replies.