admin管理员组文章数量:1293920
Is there any way to get this
<?php
$pc = new WP_Query ('category_name=cat1&posts_per_page=5');
?>
but each time display a RANDOM different batch of 5 ones?
Is there any way to get this
<?php
$pc = new WP_Query ('category_name=cat1&posts_per_page=5');
?>
but each time display a RANDOM different batch of 5 ones?
Share Improve this question edited Sep 21, 2013 at 22:45 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Sep 21, 2013 at 20:53 qaedusqaedus 4112 gold badges5 silver badges7 bronze badges 1 |1 Answer
Reset to default 41Please try this:
$args = array(
'category_name' => 'cat1',
'posts_per_page' => 5,
'orderby' => 'rand',
);
$pc = new WP_Query( $args );
where 'rand'
should give you a random order of your posts.
For more info check out the Codex on WP_Query
order parameters here.
本文标签: wp queryWPQueryrandom
版权声明:本文标题:wp query - WP_Query + random 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741590529a2387095.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
rand
order is very expensive on the database – Tom J Nowell ♦ Commented Apr 27, 2021 at 17:41