我终于找到了解决办法!
以下是查询,以防有人需要它:
// first query
$first_ids = get_posts(array(
\'fields\' => \'ids\',
\'posts_per_page\' => \'10\',
\'post_status\' => \'publish\',
\'post_type\' => array(\'post\'),
\'orderby\' => \'date\',
\'order\' => \'DESC\',
));
// second query
$second_ids = get_posts(array(
\'fields\' => \'ids\',
\'posts_per_page\' => \'10\',
\'post_status\' => \'publish\',
\'post_type\' => array(\'CPT1\'),
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'tax_query\' => array(array(
\'taxonomy\' => \'TAX1\',
\'field\' => \'slug\',
\'terms\' => \'tax_value\',
))
));
// third query
$third_ids = get_posts(array(
\'fields\' => \'ids\',
\'posts_per_page\' => \'10\',
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'post_type\' => array(\'CPT2\'),
\'tax_query\' => array(array(
\'taxonomy\' => \'TAX2\',
\'field\' => \'slug\',
\'terms\' => \'TAX2value,
))
));
// merging ids
$post_ids_list = array_merge($first_ids, $second_ids, $third_ids);
$querySlider = new WP_Query(array(
\'post_type\' => \'any\',
\'posts_per_page\' => \'10\',
\'post__in\' => $post_ids_list,
\'post_status\' => \'publish\',
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'meta_query\' => array(
array(
\'key\' => \'highlight\',
\'value\' => \'"yes"\',
\'compare\' => \'LIKE\'
)
),
));
?>
我在这里找到了解决方案:
Merge 2 args in one WP_Query and order it by date