How to hide multiple categories on home (9 posts)

  1. ZAGG
    Posted 9 years ago #

    I have 4 categories and all posts from these categories are on main page. But I just want to display posts from one particular category. How should I do it? . I have searching this forum but could not get any solution. Any help would be appreciated.
    Thank you (d'apr├ęs perfeclover)

  2. Thord Daniel Hedengren
    Posted 9 years ago #

    I'm also curious about how you do this.

  3. bob58
    Posted 9 years ago #

    Where you work through the posts (the loop), usually in the index.php of your theme, you can check for every post if it is in a certain category and display it only then.


  4. jthusgaard
    Posted 9 years ago #

    Hi I want to do the oposite.

    I have one catagory that I want to hide from all sidebare and the index page (I'll create a link directly to it).

    How do I do that?
    Where do I place the code?


  5. bob58
    Posted 9 years ago #

    Use NOT in_category() (in php it looks like if (!in_category('1')) { do it } for the main page (index.php) and for the categories overview, use the following:


    That usally happens in sidebar.php.

  6. ZAGG
    Posted 9 years ago #

    This line works on wp 1.5, bit not on 2.x and it seems that is just for one category and you cannot duplicate it several times, in order to hide multiple categories, but maybe it's an Enlightenment

    if (is_home()) {

  7. maskedmofo
    Posted 9 years ago #

    Is it possible for someone to post an actual example of a category exclusive loop. I've read this and other thread, and attempted to create a category specific loop based on the information, but I am having no success.


  8. wwjoe
    Posted 9 years ago #

    I have tried what bob58 recommended but am not sure exactly how the code is written or where it's placed, can anyone clarify or show an example? I'm trying to exclude one Catagory from showing up in the Sidebar. Thanks

  9. wwjoe
    Posted 9 years ago #

    I found a way to do this. The ID number of the Category that I don't want to show up in my Sidebar is 3. In my Sidebar.php file, there is this line of code:

    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>

    I added exclude=3 to it and you get this:

    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0&exclude=3'); ?>

    Works perfectly, hope this help, cya

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.