• 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

Viewing 11 replies - 1 through 11 (of 11 total)
  • 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.

    Thread Starter mouthybroad

    (@mouthybroad)

    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.

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

    I need the code in your sidebar.php

    Thread Starter mouthybroad

    (@mouthybroad)

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

    [long code moderated]

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

    Thread Starter mouthybroad

    (@mouthybroad)

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

    Thanks.

    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") )

    Thread Starter mouthybroad

    (@mouthybroad)

    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.

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

    Thread Starter mouthybroad

    (@mouthybroad)

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

    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.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘unapproved comments showing in sidebar’ is closed to new replies.