Previous post:

Next post:

Excluding One Category From Blog Homepage (WordPress)

by Stephanie Booth on 26.02.2007

in Wordpress

[fr]

Comment exclure une catégorie de la première page de votre blog WordPress tout en la gardant dans les archives.

[en]

The simplest method I’ve found up to now (and I’ve only just found it) if there are certain categories of posts you do not want to see appear on your main blog page, but that you still want to see in the archives, is to use query_posts().

Here’s an example:

<?php
if (is_home()) {
   query_posts($query_string . "&cat=-3");
}
?>

This needs to come in right before the while ( have_posts() ) { line. The $query_string parameter means that you can still pass parameters in the URL, so things like special Event Calendar pages will still work.

Careful, though, this only works for one category at a time. You need to use WP_Query for that, and build a separate loop for the homepage.

Similar Posts:

{ 8 comments… read them below or add one }

1 J S Zolliker 26.02.2007 at 18:37

Great to hear you solved your problem! One quiestio, though. How do you manage to get your cutomized twitter on the sidebar? I cant seem to make it work in mi site…

2 Stephanie 26.02.2007 at 19:53

I use this twitter widget http://www.velvet.id.au/twitter-wordpress-sidebar-widget/ and I customized the output somewhat.

3 J S Zolliker 26.02.2007 at 20:49

THNKS!

4 J S Zolliker 26.02.2007 at 17:37

Great to hear you solved your problem! One quiestio, though. How do you manage to get your cutomized twitter on the sidebar? I cant seem to make it work in mi site…

5 Stephanie 26.02.2007 at 18:53

I use this twitter widget http://www.velvet.id.au/twitter-wordpress-sideb... and I customized the output somewhat.

6 J S Zolliker 26.02.2007 at 19:49

THNKS!

7 Xavier 27.02.2007 at 10:25

Steph, what about using in_category() (or !in_category()) inside The Loop ?
http://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category

Seems a bit more usable than resorting to query_posts(), doesn’t it ?

8 Xavier 27.02.2007 at 9:25

Steph, what about using in_category() (or !in_category()) inside The Loop ?
http://codex.wordpress.org/The_Loop#Exclude_Pos...>

Seems a bit more usable than resorting to query_posts(), doesn't it ?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

« Back to text comment

Additional comments powered by BackType