WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: RecentComments] Exclude Trackbacks and Pingbacks from Defualt WordPress Recent Comments Wid (7 posts)

  1. Chukwudi Emmanuel Udegbunam
    Member
    Posted 4 years ago #

    My site load time is in need of drastic reduction this I'm doing away with unnecessary plug-ins.

    Please I'd like to know how to Exclude Trackbacks and Pingbacks from Defualt WordPress Recent Comments Widget without using a wordpress plug-in. The last solution to this problem offered 1 year ago in no longer valid.

    Cheers

  2. Mohammad Jangda
    Member
    Posted 4 years ago #

    Try adding this to your theme's functions.php file:

    if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
    	$comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_status = 'publish' AND comment_type IN ('comment', '') ORDER BY comment_date_gmt DESC LIMIT 15");
    	wp_cache_add( 'recent_comments', $comments, 'widget' );
    }
  3. Chukwudi Emmanuel Udegbunam
    Member
    Posted 4 years ago #

    Thanks for the fix. ;)

    BTW is there a way of getting it not to show blog author's comments?

  4. menkaur
    Member
    Posted 3 years ago #

    this seems to be the recommended solution around. But it does not work for me (at least, now).
    Here's the page:
    [URL Redacted]

    i've inserted the code, but recent comments widget still shows all the trackbacks and pingbacks

    and before you ask - i emptied all caches

  5. menkaur - I removed the URL as it as tripping the spam filter, and I can't tell if it's actually an answer or not (I'm afraid I don't speak that language). Perhaps you could just share the solution in a post?

  6. menkaur
    Member
    Posted 3 years ago #

    i DON'T SPAM.

    in any case, here's how it solved it at the end - i just dropped the standard recent comments widget and got myself "Wizzart - Recent Comments" widget. in fact, i'm very much satisfied with it

  7. I didn't say you slammed :) the spam filter is an automated thing, and has yet to reach singularity so it can make mistakes. No need to shout. But thank you for explaining, it may help many people.

Topic Closed

This topic has been closed to new replies.

About this Topic