Exclude Trackbacks from Recent Comments Listing
mysql php wordpressTo spare some time I tryed googleing for “don’t show trackbacks in recent comments” but wasn’t able to find anything relevant at first glance.
So, if you have the FreePress Recent Comments Widget and the long site titles from the trackbacks/pingbacks are breaking your design, here’s your quick tip from Vile Works:
- go to Dasboard > Plugins > Recent Comments (edit)
- find this line (line 234 in recentCommentsWidget.php):
$request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $limit";
- change it to:
$request .= "AND comment_approved = '1' AND comment_type <> 'trackback' AND comment_type <> 'pingback' ORDER BY comment_ID DESC LIMIT $limit";
What you’re doing is adding a condition in the mySQL query that the comment type should not be trackback nor pingback (trackbacks and pingbacks are also stored in the wp_comments table in the database).
Good luck!
PS: I don’t know about other recent comments plugins but this particular one offers a pretty useful fp_get_recent_comments() function you can call in your theme. Here’s what parameters you can pass into it:
- Number of comments to show: Total number of comments to display
- Number of words per comment excerpt: The first N words of the comment will be listed
- Max comments per post: This option is a “cap” to ensure that multiple posts are included in the list, even if all the recent comments were from a single post.
- Max letters per word: This option is to deal with long “words” in the comments (specifically raw URLs) that can interfere with the formating of the list, depending on the CSS rules applied.



