• Resolved rnrfowler

    (@rnrfowler)


    I am using the Recent Comments Widget that comes with WordPress 2.7 in my sidebar. How do I keep pingbacks and trackbacks from appearing in the sidebar?

    By the way, I was able to keep my own comments from appearing in the sidebar by changing this in wp-includes/widgets.php:

    Changed: $wpdb->comments WHERE comment_approved = ‘1’
    to: $wpdb->comments WHERE comment_approved = ‘1’ and user_id !=’1′

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

    (@rnrfowler)

    Okay, I tried this and it seems to be working. I added this to the code in wp-includes/widgets.php:

    and comment_type <> ‘trackback’ and comment_type <> ‘pingback’

    So, here is the original code in widgets.php:
    $comments = $wpdb->get_results(“SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1’ ORDER BY comment_date_gmt DESC LIMIT $number”);

    Here is the code removing author comments from the sidebar:
    $comments = $wpdb->get_results(“SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1’ and user_id !=’1′ ORDER BY comment_date_gmt DESC LIMIT $number”);

    Here is the code removing trackbacks and pingbacks from the sidebar:
    $comments = $wpdb->get_results(“SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1’ and comment_type <> ‘trackback’ and comment_type <> ‘pingback’ ORDER BY comment_date_gmt DESC LIMIT $number”);

    And here is the code removing author comments and trackbacks and pingbacks from the sidebar:
    $comments = $wpdb->get_results(“SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1’ and user_id !=’1′ and comment_type <> ‘trackback’ and comment_type <> ‘pingback’ ORDER BY comment_date_gmt DESC LIMIT $number”);

    I hope that helps. It seems to be working fine on my sidebar.

Viewing 1 replies (of 1 total)
  • The topic ‘How do I prevent trackbacks from appearing in Recent Comments Widget?’ is closed to new replies.