WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to exclude front page categories in WP2.3?

[Resolved] How to exclude front page categories in WP2.3?

  • Looking at the codex, and searching here, I can’t see any reason why excluding categories from the loop like this:

    if (in_category('39') ) continue

    wouldn’t work. But it doesn’t seem to.

    The old Ryan plug “front page categories” which I’ve relied upon for so long doesn’t work anymore in 2.3

    How do you exclude more than one category (ex: 39, 40, 41, 42) from the index (home) now?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Yeah, I noticed this problem too. First it scared the SH&T out of me, but soon I noticed it would be the Front Page Categories plugin.

    So if anyone has any idea how to resolve this? PLEASE????

    hmmm…

    in your index.php theme page, you’ll have something like the following, beginning the loop.

    <?php while (have_posts()) : the_post(); ?>

    The easiest (and IMO best) way to exclude multiple cats is to make that read something like:

    <?php if (is_home()) query_posts("cat=-39,-40,-41");
     while (have_posts()) : the_post(); ?>

    note the negative cat numbers.

    That’ll exclude them and still respect your max post count for the index page.

    awesome

    thank you!!!!

    Thank you SOOO much! I love this simple right to the point solution! Thank you IVOVIC!

    you’re welcome guys… now mark the thread resolved 😉

    yeah this doesn’t appear to work. My page goes blank when I use the above code, any suggestions?

    Sweet, thanks for the reply and link, works for the latest version of wp which is 2.3 ;op

    That is an excellent plugin. I had been looking for something like this for a long time to use in conjunction with the CategoryAccess plugin.

    I know it’s an old post but maybe this could be of some use for someone :).

    You can also choose to include the categories you would like to show on frontpage (comes in handy when there are more categories to be excluded than included 😉 ).

    Open the index.php file and switch this piece of code:

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

    with this:

    <?php if (have_posts()) : ?>
    <?php query_posts(‘cat=1’); ?>
    <?php while (have_posts()) : the_post(); ?>

    Where number 1 in ‘cat=1’ denotes the ID of the category you want to show on your home page. If you want to show cateogories with IDs 1,3 and 4 on your front page the line should go

    <?php query_posts('cat=1,3,4'); ?>

    Good luck :)!

    cikorka: Very good! I fiddled around with these other suggestions in WP2.5.1 with little success. This simple approach works great!

    A note: There’s no need to split up the PHP statement – the following works just as well:

    <?php if (have_posts()) : query_posts('cat=1,2,3'); while (have_posts()) : the_post(); ?>

    And to exclude instead of include, just use this format for the query_posts statement above:

    query_posts('cat=-1,-2,-3');

    As always, WordPress is the bees knees, and so is the support forum! Rock on, guys (and gals).

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Resolved] How to exclude front page categories in WP2.3?’ is closed to new replies.
Skip to toolbar