Exclude category from recent comments list
-
I have a snippet of code to display recent comments that works great, but I’ve created a category that is ‘private’ and need to exclude any comments made on posts from that category from showing up in the list of recent comments.
Here is what I’m using to display the list of recent comments:
<?php global $comment; if ( $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved='1' AND comment_type='' ORDER BY comment_date_gmt DESC LIMIT 10") ) : ?> <ul> <?php foreach ($comments as $comment) { echo '<li>' . sprintf('%s <span style="text-transform: lowercase;">on </span>%s', get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>'); echo '</li>'; } ?> </ul> <?php endif; ?>
I’m not sure how, or even if, it can be modified to exclude a single category’s comments.
Any ideas?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Exclude category from recent comments list’ is closed to new replies.