How To Create Popular Post without Plugin


Sponsored Links




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

Create Popular Post without Plugin - Jennifer Lopez on Boys & Girls Club

Create Popular Post without Plugin - Jennifer Lopez on Boys & Girls Club

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

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net


4 Responses to How To Create Popular Post without Plugin

  1. Pingback: Tweets that mention How To Create Popular Post without Plugin # WordPress Tricks & Tips -- Topsy.com

  2. 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.

  3. Pradeep says:

    Hi, I wanted to know, How can we get the popular posts by view count without plugin?
    thanks.

  4. Damn says:

    I’m also using wordpress and use this popular post as a “must” menu to see most commented post

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>