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.

Count WordPress Comments with Specific Meta Value and Post ID

原文地址: https://www.cveoy.top/t/topic/oycp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录