Recent Comments from Specific Category – Side Bar
-
Greetings..
I looked extensively for this issue throughout WordPress and could not find an answer. Currently I have code setup to grab the most recent comments. However, I want it to only grab the most recent comments from a specific category, Category ID: 11.
Here is the existing code:
<?php if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 5"); wp_cache_add( 'recent_comments', $comments, 'widget' ); } if ( $comments ) : foreach ( $comments as $comment): echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>'; endforeach; endif; ?>
Please help and thank you in advance.
- The topic ‘Recent Comments from Specific Category – Side Bar’ is closed to new replies.