Today WP Tricks is how to create popular post without any plugin. We need to run little bit query using some code and place this code on whatever you want to put on. Example we can put this code on the sidebar.php or footer.php
To Create Popular Post without any plugin, please write down this code on your sidebar.php or footer.php
<h2>Popular Posts</h2>
<ul>
< ?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="< ?php echo $title ?>">< ?php echo $title ?></a> {< ?php echo $commentcount ?>}</li>
< ?php } } ?></ul>
Please note, this popular post based how many comment. More comment it’s mean more popular post.
Photo source Egotastic




Pingback: Tweets that mention How To Create Popular Post without Plugin # WordPress Tricks & Tips -- Topsy.com
Your idea is really resourceful, I am using wordpress,.com and I wasn’t able to use plug ins as I did not upgrade the hosting, all I know is that plug ins can run blog more popular than ever, but after seeing this intelligent instruction, I never knew that it could be possible to do so without plug in. Thanks for sharing.
Hi, I wanted to know, How can we get the popular posts by view count without plugin?
thanks.
I’m also using wordpress and use this popular post as a “must” menu to see most commented post