子帖子与其父母相关(通过“post\\u parent”字段),反之亦然。因此,您必须首先查询子帖子类型,然后获取所有结果的父项。
// obviously these variable names and key names might not apply,
// change them as necessary
$performances = get_posts( array(
\'meta_key\' => \'the_performance_date_custom_field\',
\'meta_value\' => $date,
\'post_type\' => \'performance\' ) );
// extract the parent post ID\'s from each of the returned performances
$event_ids = array_map(
create_function(\'$post\',\'return $post->post_parent\'),
$performances );
$event_ids = array_unique( $event_ids ); // dump any duplicate events
// and finally, get the events from their ids
$events = get_posts( array(
\'post_type\' => \'event\',
\'post__in\' => $event_ids ) );