Last updated on January 22nd, 2022 at 07:11 pm
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.