我尝试了这种方法,但是在WP_Query类中orderby和order不起作用。
$posts = new WP_Query(
array(
'post_type'=> 'block_code',
'orderby'=> 'post_date',
'order' => 'DESC'
)
);
通常它返回 orderby=> 'menu_order' 和 order='ASC' 。
注意:如果我在URL中使用参数 orderby=date&order=ASC ,则它可以正常工作,但我需要用作 WP_Query 的参数。
提前致谢