Support » Plugins » Popular Posts Plugin

  • I have spent the last 2 hours googling and searching for a popular posts plugin that works with 2.5. I can not find one thing that works.

    Has anyone done this in 2.5? I would also like it to grab an image as well from the post if possible.


Viewing 7 replies - 1 through 7 (of 7 total)
  • That makes two of us. I love the idea of the Popularity plugin, but it definitely doesn’t work with the latest WordPress (2.6).

    Bumping this up 😀

    SELECT comment_post_ID , COUNT(comment_post_ID)
    FROM wp_comments
    GROUP BY comment_post_ID
    ORDER BY COUNT( comment_post_ID ) DESC
    LIMIT 10 ;

    This SQL statement does the trick. It returns the 10 most commented upon post IDs.

    Now if someone can make a plugin out of this …

    Er. There is something much easier –

    FROM wp_posts
    ORDER BY comment_count DESC
    LIMIT 10;

    D’oh. If you want to show the 5 most popular posts in your template, you can use something like this –

    	$sql='SELECT post_title, comment_count, guid
    		FROM wp_posts
    		ORDER BY comment_count DESC
    		LIMIT 5;';
    	$results = $wpdb->get_results($sql);
    	foreach ($results as $r) {
    		echo '<li><a href="' . $r->guid . '" title="' . $r->post_title . '">· ' . $r->post_title .
    			' <em>(' . $r->comment_count . ')</em></a></li>';

    Before WP 2.5 it was possible to use:
    $lastposts = get_posts('numberposts=10&orderby=comment_count&offset=0');

    Is there no function that works simpler ones as the solution of pravin?

    pravin, where should i edit this script? in which file?

    haimski … in your template file, where you need it.
    Most probably in a sidebar.php, otherwise in the index.php.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Popular Posts Plugin’ is closed to new replies.