Return to Snippet

Revision: 303
at July 9, 2006 03:46 by championeer


Initial Code
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

 <!-- If the post is in the category we want to exclude, we simply pass to the next post. -->
 <?php if (in_category('3')) continue; ?>
 
 <div class="post">
 
  <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
 
  <small><?php the_time('F jS, Y'); ?></small>
 
  <div class="entry">
    <?php the_content(); ?>
  </div>

  <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
 </div> <!-- closes the first div box -->

 <?php endwhile; else: ?>
 <p>Sorry, no posts matched your criteria.</p>
 <?php endif; ?>

Initial URL


Initial Description
Exclude Posts From Some Category
这样就可以在首页中不显示某些类别(比如asides)的帖子了

Initial Title
在wordpress主循环中过滤掉指定类别中的帖子

Initial Tags
wordpress, filter

Initial Language
PHP