Can two comments widget, to collect two different lists of recent comments from different pages?

Suppose there are two pages "A" and "b", each with three links to other pages with enabled comments. Is it possible to make comments widget on the page "And" display recent comments from three of "their" pages, and a widget "In the" display recent comments with three of"his" pages? Is it possible ? Or any installed widget will always be a machine to collect all comments from all pages ?
March 19th 20 at 09:16
2 answers
March 19th 20 at 09:18
Standard widget - no. But you can easily make your own based on it. Of program it is quite possible.
March 19th 20 at 09:20
The easiest way so far I found a plugin to add php to a widget and the code
function last_comments($src_count=5, $src_length=50) {
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, user_id, comment_content, comment_approved,
SUBSTRING(comment_content,1,$src_length) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)
WHERE comment_approved = '1' AND comment_type = "AND post_password ="
ORDER BY comment_date_gmt DESC
LIMIT $src_count";
$comments = $wpdb->get_results($sql);
foreach ($comments as $comment) {
$comment->com_excerpt = strip_tags( $comment->com_excerpt );
$output .= "";
$output .= "" .$comment->comment_author. "";
$output .= ": ID) . "#comment-" . $comment->comment_ID . "\" >" ......";
$output .= "";
echo $output;
Anyone can help how to add the post id parameter or the category_name? the posts below were derived based on these criteria ?
In General added parameter: AND post_title = 'sample post 1', and lo and behold, the widget started to display the comments from the post called "example post 1", but how to specify multiple kinds of posts, what's the syntax ?

Find more questions by tags WordPress