• I was wondering if anyone if there’s a plugin, hack, or whatever else that would enable me to display the top 5 most recently discussed posts. Meaning, every time a post was commented on, it would go to the top of the list, and it would display how many posts. For an example of what I mean, check out the top right of http://www.deadyetliving.com/index.shtml
    Can anyone help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Unfortunately, the plugin API is geared more for actions upon posting, editing, commenting, etc; and falls a little short for actions to take when visitors load the page. The exception is wp_head, which may work for this instance.
    You could make a hack pretty easily, though. All you need the following SQL query:
    SELECT * FROM wp_comments
    ORDER BY comment_date DESC LIMIT 5

    You can use that in a php function as such:
    <?php
    $sql = "SELECT * FROM wp_comments ORDER BY comment_date DESC LIMIT 5";
    $result = $wpdb->get_result($sql);
    foreach ($result as $nonce) {
    echo $nonce['Title'];
    ?>

    I haven’t tested that yet, so it may not work; but the SQL query is functional (and tested).

    Hmm, I think there’s more to it than just the wp_comments table. You’d need to reference the wp_posts tables as well to get the title. 😉
    The easiest way (if you have WP 1.2 installed) is to go here:
    http://mtdewvirus.com/wp-hacks/
    Download the Plugins.zip file
    Within the file are 5 plugins you can use. The plugin you want is probably recent-comments.php
    Upload that file into wp-content/plugins
    Then go into your control panel -> plugins
    and activate Recent Comments
    And in your index page, put
    <? get_recent_comments(5, 7, ”, ‘
    ‘, true); ?>
    where you want the list of new comments to be displayed. 🙂

    Thread Starter superbird

    (@superbird)

    Two problems with that solution:
    1. There is no post title displayed.
    2. If there were, there would probably be duplicates. Like two of the same post there.

    If you want everything, use this SQL query:
    SELECT DISTINCT * FROM wp_comments LEFT JOIN wp_posts on (wp_comments.comment_post_id = wp_posts.ID) ORDER BY wp_comments.comment_date DESC LIMIT 5;

    Thread Starter superbird

    (@superbird)

    How would that look in, say, the finished plugin file? Also, how exactly would I call it in the index.php file?
    Sorry, I’m pretty darn new at this php stuff.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Recently Discussed Plug-in’ is closed to new replies.