我有一个简单的WP\\U查询,可以按日期获取合著者(分类法作者)的帖子列表,这是一个查询:
$username = get_the_author_meta( \'login\', $author_id );
$args = array(
\'post_type\' => \'any\',
\'orderby\' => \'date\',
//\'orderby\' => \'post_date\',
\'order\' => \'DESC\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'author\',
\'field\' => \'name\',
\'terms\' => $username
)
)
);
$query = new WP_Query( $args );
结果总是一个按日期排序的帖子列表。。。我已经在internet上搜索解决方案,但没有成功。。。有什么想法吗?
非常感谢
最合适的回答,由SO网友:Pravin Work 整理而成
这肯定会奏效。。。。这对我有用。。。
$username = get_the_author_meta( \'login\', $author_id );
$args = array(
\'post_type\' => \'any\',
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'suppress_filters\' => true,
\'tax_query\' => array(
array(
\'taxonomy\' => \'author\',
\'field\' => \'name\',
\'terms\' => $username
)
)
);
$query = new WP_Query( $args );