Comments Filtering for MP-WP

November 29th, 2019

To fix the Recent Comments widget so that it stops messing about with trackbacks/pingbacks where they don't belong (aka in your sidebar), you'll need just a tiny change to wp-includes/widgets.php so that it becomes a bit more discerning when selecting stuff from the comments table1, quoth the .vpatch:

- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' and comment_type = '' ORDER BY comment_date_gmt DESC LIMIT $number");

And to make this .vpatch worth at least two lines instead of just one, I also fixed the "default" theme so that it orders the comments at the bottom of an article: trackbacks and pingbacks should be shown there but *only* at the bottom, not messing up people's conversation. The change is made in wp-content/themes/default/comments.php as the .vpatch says:

< ol class="commentlist" >
- < ?php wp_list_comments(); ? >
+ < ?php wp_list_comments('type=comment'); ? >
+ < ?php wp_list_comments('type=pings'); ?>
< /ol >

While I looked into applying the same approach to fix the "classic" theme too, the sadness is that the classic theme takes a different approach to comments and so the required change wasn't that obvious to me right now. I'm no expert in php or mp-wp and I'm not all that keen at becoming one either so I left it for now at this and I have no claim that the solution is anything other than something that works on my blog.

The .vpatch sits on top of billymg's current v-tree head and hopefully doesn't break anything but I'm sure he'll let me know if it does2 :


  1. line 1392 in my file 

  2. According to the "no news is good news" principle, if he doesn't complain, then I'll consider it's all absolutely perfect.