[wp-hackers] Exclude Categories From The Loop
Jared Bangs
jared at pacific22.com
Fri Oct 5 05:46:29 GMT 2007
On 10/4/07, Matt <speedboxer at gmail.com> wrote:
> On 10/4/07, Daniel Cameron <dan at scatter3d.com> wrote:
> >
> > I currently use this plugin,
> > http://wordpress.org/extend/plugins/sideblog/
> >
> Thanks, but I meant inside of my own plugin... I want to have a category
> that doesn't show up in the loop, without the user having to change their
> loop in their theme files. So, is there like a filter or something to do
> this?
Untested pseudo-code partially extracted from the sideblog plugin
mentioned above:
function my_post_filter($query) {
global $wp_query;
if(!is_category() && !is_single() && !is_tag()){
$wp_query->set('category__not_in',$arrayOfCategoriesToIgnore);
}
add_action('pre_get_posts','my_post_filter');
- Jared
More information about the wp-hackers
mailing list