如何在主循环中排除特定的分类
September 15th, 2008 Denis
<?php if ( have_posts() ) : query_posts($query_string .'&cat=-13,-26'); while ( have_posts() ) : the_post(); ?>
另外还有一个插件可以帮你做这件事情:Advanced Category Excluder,通过在特定页面(如:搜索结果页,RSS ,分类列表页面或者日志页面)隐藏特定分类来增强 WordPress的功能。
翻译自:Most Desired WordPress Hacks: 11 Common Requests and Fixes 第六点。
作者:Denis
原文链接:如何在主循环中排除特定的分类





1. mylaner | September 15, 2008 at 1:49 am | #
沙发!
2. fisio | September 15, 2008 at 3:02 am | #
codex.wordpress.org
随身手册,博客必备~
3. SHA Miao | September 15, 2008 at 10:30 am | #
牛
加星
4. istef | September 15, 2008 at 8:41 pm | #
貌似在 query_posts 之前不用判断 have_posts(), 在 query_posts 之后最好判断一下。
另外 query_posts 会扰乱 WP 默认的分页之类的东西,用起来不是很爽
5. Denis | September 15, 2008 at 9:25 pm | #
嗯,所以最好用 WP_Query 类。
6. 二手科学家 | September 18, 2008 at 9:23 am | #
我用的就是Advanced Category Excluder,之前试过Query 类,确实有问题
7. cnpabi | October 11, 2008 at 9:11 pm | #
牛B的