WordPress.org

Forums

[resolved] How to exclude front page categories in WP2.3? (13 posts)

  1. dss
    Member
    Posted 7 years ago #

    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?

  2. auxillary
    Member
    Posted 7 years ago #

    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????

  3. dss
    Member
    Posted 7 years ago #

    hmmm...

  4. Ivovic
    Member
    Posted 7 years ago #

    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.

  5. dss
    Member
    Posted 7 years ago #

    awesome

    thank you!!!!

  6. auxillary
    Member
    Posted 7 years ago #

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

  7. Ivovic
    Member
    Posted 7 years ago #

    you're welcome guys... now mark the thread resolved ;)

  8. qwik3r
    Member
    Posted 7 years ago #

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

  9. Chris_K
    Member
    Posted 7 years ago #

  10. qwik3r
    Member
    Posted 7 years ago #

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

  11. jwurster
    Member
    Posted 7 years ago #

    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.

  12. cikorka
    Member
    Posted 7 years ago #

    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 :)!

  13. timjamz
    Member
    Posted 7 years ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Topic