📜  wordpress php 查询随机化 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:37.455000             🧑  作者: Mango

代码示例1
//Create WordPress Query with 'orderby' set to 'rand' (Random)
$the_query = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => '1' ) );
// output the random post
while ( $the_query->have_posts() ) : $the_query->the_post();
    echo '
  • '; the_title(); echo '
  • '; endwhile; // Reset Post Data wp_reset_postdata();