【发布时间】:2013-07-03 08:37:03
【问题描述】:
我正在使用 while 循环
while (have_posts()) : the_post();
获取所有帖子并显示一个页面。如何随机发布帖子。但问题是,在我正在处理的页面中没有“查询”的迹象。我也尝试使用提到的一些解决方案,但没有结果。
【问题讨论】:
标签: wordpress while-loop
我正在使用 while 循环
while (have_posts()) : the_post();
获取所有帖子并显示一个页面。如何随机发布帖子。但问题是,在我正在处理的页面中没有“查询”的迹象。我也尝试使用提到的一些解决方案,但没有结果。
【问题讨论】:
标签: wordpress while-loop
您可以通过这种方式使用query_posts($args) 更改主查询:
// Alter the query
query_posts( 'orderby=RAND' );
while ( have_posts() ) : the_post();
// Do your stuff inside the loop
endwhile;
// Reset the query
wp_reset_query();
【讨论】: