WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] orderby comment_count being ignored (2 posts)

  1. Sture2020
    Member
    Posted 3 years ago #

    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?

  2. Sture2020
    Member
    Posted 3 years ago #

    Problem found.

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

Topic Closed

This topic has been closed to new replies.

About this Topic