Count comments of post id that have specific meta value in wordpress by query this is my query $comments = get_comments array meta_query = array array key = rating valu
You can add the post ID as a parameter in the get_comments function to filter the comments for a specific post. Here's the modified query:
$comments = get_comments( array(
'post_id' => $post_id, // replace $post_id with the actual post ID
'meta_query' => array(
array(
'key' => 'rating',
'value' => '5',
),
),
) );
This will return an array of comments that have a meta value of 5 for the rating key and are associated with the specified post ID as their parent
原文地址: https://www.cveoy.top/t/topic/gL1y 著作权归作者所有。请勿转载和采集!