/ Published in: PHP
Exclude Posts From Some Category
è¿™æ ·å°±å¯ä»¥åœ¨é¦–页ä¸ä¸æ˜¾ç¤ºæŸäº›ç±»åˆ«ï¼ˆæ¯”如asides)的帖å了
è¿™æ ·å°±å¯ä»¥åœ¨é¦–页ä¸ä¸æ˜¾ç¤ºæŸäº›ç±»åˆ«ï¼ˆæ¯”如asides)的帖å了
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?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; ?>