WordPress排除调用某个分类下的文章

技术文档 2024年1月18日

wordpress在调用分类下文章时,有时需要排除调用某个分类的文章,下面的这段代码,就可以轻松实现不调用特定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; ?>

相关文章