1

I am trying to show the most commented post. Only one post should show but I am getting 2 even though the number of comments is not the same?

<?php $args = array(
        'orderby' => 'comment_count',
        'posts_per_page' => 1,
      );
      $most_commented = new WP_Query($args); 
?>
<?php if ($most_commented->have_posts() ):
            while ($most_commented->have_posts() ): $most_commented->the_post();
            $author_id = get_the_author_meta( 'ID' );
?>

  <?php // display info about blog post here ?>

<?php endwhile; wp_reset_postdata(); ?>
<?php endif; ?>
2
  • 4
    If you have sticky posts they'll be included unless you use 'ignore_sticky_posts' => true. Do you have a sticky post? Jul 29 '20 at 11:08
  • 1
    This seems do do the trick. Can you add it as an answer so I can mark as accepted? Thanks! Jul 29 '20 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.