使用get_comments( $args )
获取帖子的所有评论。
$args= array(
\'author_email\' => \'\',
\'ID\' => \'\',
\'karma\' => \'\',
\'number\' => \'\',
\'offset\' => \'\',
\'orderby\' => \'\',
\'order\' => \'DESC\',
\'parent\' => \'\',
\'post_id\' => 0,
\'post_author\' => \'\',
\'post_name\' => \'\',
\'post_parent\' => \'\',
\'post_status\' => \'\',
\'post_type\' => \'\',
\'status\' => \'\',
\'type\' => \'\',
\'user_id\' => \'\',
\'search\' => \'\',
\'count\' => false,
\'meta_key\' => \'\',
\'meta_value\' => \'\',
\'meta_query\' => \'\');
您可以设置
post_id
请点击此处获取与该帖子相关的所有评论。它与您的查询相同。
$comments = get_comments(array(\'post_id\'=> \'your post id\'));
$comment_ids = array();
foreach($comments as $comment):
$comment_ids[] = $comment->comment_ID;
endforeach;
print_r(comment_ids);
供参考
http://codex.wordpress.org/Function_Reference/get_comments