• Resolved lukehimselfnet

    (@lukehimselfnet)


    Hi,

    I want to put what appears on the default “Recent Comments” widget elsewhere in my blog, on a non-widget area.

    I’ve looked around and wasn’t sure how to locate the code? There’s some other code around for different Recent Comments, but I specifically want the default WordPress style.

    My blog is lukehimself.net and I want to put it at the bottom in a <div>.

    Thanks,
    Luke.

Viewing 1 replies (of 1 total)
  • Thread Starter lukehimselfnet

    (@lukehimselfnet)

    I worked it out using this code, for anyone who searches the same thing.

    <?php
    $number=5; // number of recent comments desired
    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
    ?>
    <ul id="recentcomments">
    <h2>Recent Comments</h2>
    <?php
    if ( $comments ) : foreach ( (array) $comments as $comment) :
    echo  '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a>comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '';
    endforeach; endif;?>
Viewing 1 replies (of 1 total)

The topic ‘Recent Comments Code’ is closed to new replies.