您可以首先尝试以下注释查询:
$comments = get_comments(
[
\'post_type\' => \'projects\',
\'post_status\' => \'publish\',
\'type\' => \'message\',
\'date_query\' => [
[
\'before\' => \'5 days ago midnight\',
\'inclusive\' => true,
]
],
\'meta_query\' => [
[
\'key\' => \'foo\', // <-- Adjust to your needs!
\'value\' => \'bar\' // <-- Adjust to your needs!
]
]
]
);
然后通过以下方式收集帖子ID:
$post_ids = array_unique( wp_list_pluck( $comments, \'comment_post_ID\' ) );
您可能需要考虑使用
number
属性
然后,您可以将其用于:
$query = new WP_Query( [ \'post__in\' => $post_ids, ... ] );
对于非空
$post_ids
大堆