你仍然可以使用get_posts
:
$parents = get_posts(
array(
\'posts_per_page\' => -1,
\'post_type\' => \'my_custom_post_type\',
\'fields\' => \'ids\', // Just get IDs, not objects
\'tax_query\' => array(
array(
\'taxonomy\' => \'my_custom_tax\',
\'field\' => \'slug\',
\'terms\' => array(
\'foo\',
\'bar\',
),
),
),
)
);
$post_ids = get_posts(
array(
\'posts_per_page\' => -1,
\'post_parent__in\' => $parents,
\'post_type\' => \'my_custom_post_type\',
\'fields\' => \'ids\',
\'meta_query\' => array(
array(
\'key\' => \'my_custom_field\',
\'value\' => $foobar,
),
),
)
);
进一步阅读
tax queries 和
meta queries.