WordPress调用网站随机文章

技术文章 2024年1月18日

wordpress实现随便文章显示的方法

<?php
  
  query_posts("showposts=10&orderby=rand"); //showposts=10表示10篇
  
  while(have_posts()): the_post();
  
  ?>
  
  <li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title() ?></a></li> //这里可以写成你自己需要的样式
  
  <?php endwhile; ?>

相关文章