<?php
$rp = new WP_Query(array(
\'post_type\' => array( \'post\',\'videos\',\'projects\' ),
\'orderby\' => \'date&order=DESC\',
\'posts_per_page\' => 4
));
while ($rp->have_posts()) : $rp->the_post();
?>
我注意到如果我改变
date&order=DESC
到
rand
, 这没有什么区别,这意味着即使在多次刷新之后,帖子也不会以随机顺序出现。这个代码有什么问题吗?
最合适的回答,由SO网友:Evan Yeung 整理而成
应该是这样的:WP_Query Order By Parameters
<?php
$rp = new WP_Query(array(
\'post_type\' => array( \'post\',\'videos\',\'projects\' ),
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'posts_per_page\' => 4
));
while ($rp->have_posts()) : $rp->the_post();
?>