• Resolved junihh

    (@junihh)


    I’m working on my own first theme designe for my blog. Because i don’t know how to make widgets i’m coding the sidebar manually. Now i need to list the recent comments on the sidebar but not using a widget.

    There’s a way to list the recent comments without a widget ???

Viewing 12 replies - 1 through 12 (of 12 total)
  • Just ripped this out of wp-includes/widgets.php

    <?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 href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
    endforeach; endif;?></ul>

    There’s probably a plugin (without a widget) that could also do this.

    Thread Starter junihh

    (@junihh)

    Hey, thanks for your help, that working for me. This is what i did with that code (in the sidebar > Comentarios tab box).

    Thanks again for your help.

    Thread Starter junihh

    (@junihh)

    @michaelh, sorry that i complicated a bit more but is there a way to show only the comments from my visitors and exclude my own comments ???

    set the WHERE clause to something like this:

    WHERE comment_approved = '1' AND user_id != '5'

    Of course you need to use your user id in place of the 5.

    Thread Starter junihh

    (@junihh)

    Great, that working for me. Thanks again.

    Aha! (light turns on) very helpful indeed.
    Used it to list author comments on the profile page (author.php)
    by adding ..AND user_id='".$curauth->ID."'.. to the db query.

    @snaggletooth -I have been trying to figure that out for weeks to show just comments from the author on profile page.

    Could you please share the code. I don’t understand where to put the little snippet of code you referenced.

    Thanks in advance.

    hi.
    so is there a way to add to this snippet of code so that the actual comments are shown as well? i’d like very much to show the comment (or at least part of it), the user’s screen name, the user’s gravatar and the article (post) name.

    anyone got a some info or a lead to follow for this?

    Just adding to cornhustlah’s request for implementing a snippet of the excerpt as well!

    I was thinking I could do something with <?php comment_excerpt(); ?>
    but it is not as straightforward as I hoped.

    Did anybody find a plugin that doesn’t use a widget?

    $comment_content = strip_tags($comment->comment_content);
    $comment_content = stripslashes($comment_content);
    echo $comment_content;

    apply where needed ??

    How do you limit the number of characters (or lines, maybe) for the comments?

    wath is the code for only display the title post , that was commented … i do not want to display who posted and site

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘List recent comments’ is closed to new replies.