How to display popular post WordPress

Last updated on August 19th, 2022 at 09:55 am

How to display WordPress posts without plugin is what we are discussing below. I came across different WordPress themes in which they normally don’t have an option/widget to display popular post category. This a simple tutorial/tip to help you display popular post in WordPress. The SIDEBAR.PHP is the best location where we can put this code. Make sure to take a back up of the file you are modifying.

<h3>Popular Posts</h3>
<ul>
<?php query_posts('category_name=php&showposts=10'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a><br /> <?php the_excerpt(); ?>
</li> <?php endwhile; ?>
<?php endif; ?>
</ul>

The above code will show the top 10 most popular posts. The category name is optional, you can give any thing of your wish. I have given the category name as PHP.

Demo

Click to rate this tutorial!
[Total: 2 Average: 4]

4 replies on “How to display popular post WordPress”

Leave a Reply

Your email address will not be published. Required fields are marked *