恐怕你得跟Direct MYSQL
或者你可以跑两个WP_Query()
然后将其组合、排序或排序WP_Query()
然后将它们合并。
下面是一个示例
$args = array(
\'post_type\' => array( \'staff-updates\', \'coreteam\',
\'developing-updates\', \'vacancies\', \'recognition\', \'page\' ),
\'orderby\' => \'modified\',
\'posts_per_page\' => \'10\',
\'order\' => \'DESC\',
);
$the_query_modified = new WP_Query( $args );
$args = array(
\'post_type\' => \'employees\',
\'orderby\' => \'date\', //default to post_date
\'posts_per_page\' => \'10\',
\'order\' => \'DESC\',
);
$the_query_published = new WP_Query( $args );
$combined = new WP_Query();
//combining two to one
$combined->posts = array_merge( $the_query_modified->posts, $the_query_published->posts );
现在
$combined->posts
两者都有。那你想怎么做就怎么做。
$combined
可能会遗漏一些细节,因为它不是直接构造的。在这种情况下,您只需使用两个查询(
$the_query_modified
,
$the_query_published
) 直接或转到SQL