WordPress.org

Ready to get started?Download WordPress

Forums

unapproved comments showing in sidebar (12 posts)

  1. mouthybroad
    Member
    Posted 5 years ago #

    Hi - I have wordpress blog, it's a self install on the servers at my ISP. The comments and comment spam that I get, even when it's held for moderation or unapproved, shows up on my front page sidebar. It remains there until I delete it. This happens with SpamKarma and WordPress HashCash.

    Does anyone know how to disable unapproved comments, spam or no, from appearing in the sidebar?
    Thanks

  2. Darran
    Member
    Posted 5 years ago #

    We can modify the code to only display approved comments, but we need to know what is it you are having displayed in your sidebar.

  3. mouthybroad
    Member
    Posted 5 years ago #

    Hi, thanks Darran. This is the url: http://www.mouthybroad.com/
    On the right side under comments, it's clearly spam, and unapproved. Please let me know what to do, I appreciate it.

  4. Darran
    Member
    Posted 5 years ago #

    This code cannot be seen from your website's source.

    I need the code in your sidebar.php

  5. mouthybroad
    Member
    Posted 5 years ago #

    Hi Darran-
    Sorry. Here it is:
    after begin sidebar:

    [long code moderated]

  6. moshu
    Member
    Posted 5 years ago #

    Don't post code here: nobody can read it. Use a pastebin service: http://wordpress.pastebin.ca and post back the URL.

  7. mouthybroad
    Member
    Posted 5 years ago #

    Sorry, didn't know that. Here is the link to the code:
    http://wordpress.pastebin.ca/1203418

    Thanks.

  8. Darran
    Member
    Posted 5 years ago #

    Replace

    if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT 5") )

    with

    if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE $wpdb->comments.comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5") )

    This will get you to display approved comments including trackbacks and pingbacks. Should you wish to have only comments listed, use the following.

    if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE $wpdb->comments.comment_approved = '1' AND $wpdb->comments.comment_type = '' ORDER BY comment_date_gmt DESC LIMIT 5") )

  9. mouthybroad
    Member
    Posted 5 years ago #

    You are awesome! Thank you so much! I am assuming I will have to do this for any theme that I download, correct?

    Thanks again.

  10. Roy
    Member
    Posted 5 years ago #

    I've never had a theme that showed unapproved comments. It's easy to test, though, do they appear on classic or default theme?

  11. mouthybroad
    Member
    Posted 5 years ago #

    This was a theme called Devenir En Gris 1.5 by Frederic de Villamil aka neuro. Have at it. Thanks!

  12. Darran
    Member
    Posted 5 years ago #

    Usually most theme developers would not want their theme showing spam comments, I do not understand why it was not the case. More often than not, you would not need to edit the query, that is of course down to the theme developer.

Topic Closed

This topic has been closed to new replies.

About this Topic