WordPress调用指定分类ID下的文章

技术文档 2024年1月18日

调用特定分类的方法,只需要知道他的ID就可以实现,调用方式如下

<?php
  
  query_posts("showposts=10&cat=1"); //cat=1为调用ID为1的分类下文章
  
  while(have_posts()) : the_post(); ?>
  
  <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
  
  <?php endwhile; ?>

相关文章