WordPress.org

Support

Support » How-To and Troubleshooting » exclude post from main index

exclude post from main index

Viewing 6 replies - 1 through 6 (of 6 total)
  • Do you mean the on any page or just the home page?

    If the home page, copy your index.php and name it home.php and edit the loop.
    If any page, edit the loop in your index.php

    Check out this section for the codex page on the_loop: http://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category

    It never hurts to search:
    http://wordpress.org/search/exclude+category+main+page?forums=1
    (there are several plugins doing it…)

    affysucks
    Member

    @affysucks

    It did do a search but it came up with a “category visibility” plugin by Rich Hamilton.

    It does the job just fine but I want exclude all entries on a particular category from all pages of my website but the entries i want to hide seems to pop up under “most recent entries” and under calender

    All I want to accomplish is to make all entries on a particular category to not appear on all pages of my site, unless they typed in the exact permalink of the hidden entry on the address bar.

    Any suggestions?

    Seems like this should be a standard WP feature…

    For excluding posts in the Recent Posts list, check out this widget:

    http://blue-anvil.com/archives/create-a-wordpress-recent-posts-widget

    I haven’t tried it yet but it sounds promising! You’ll have to combine it with code that excludes the category from the main page (see blepoxp or rudolf45 posts or http://blogulate.com/content/exclude-categories-from-wordpress-frontpage/ BUT note that the posts are still counted even though they’re not shown), so it’s a bit of a pain but…

    blogsnapper
    Member

    @blogsnapper

    Another way of excluding more than one category from the home page is to add a small piece of code in your template (index.php etc).

    Look for (should be somewhere between line 1-20):
    <div class="post" id="post-<?php the_ID(); ?>">
    Insert this directly above:
    <?php if ((in_category(1) || in_category(2)) && is_home() ) continue; ?>

    Explanation: The code in this example looks for posts from categories with id 1 and 2. If they exist and the visitor are on the home page (is_home), they are hidden.
    If the visitor are viewing another category page than home, the posts will be visible.

    Exclude one category only?
    If you only want to exclude/hide one single category from the home page, use this code instead:
    <?php if (in_category('1') && is_home() ) continue; ?>

    Remember!
    Hiding a category won’t make it invisible to the system. If you have specified to show 10 posts in a category page and 3 of the posts are hidden (as described above), the total amount of visible posts will be 7. The system will not add three new posts from the archive since it consider it allready shows 10 (as defined in dashboard). More advanced code is needed to accomplish this.

    This solution has been tested in WordPress 2.5

    Enjoy,
    //Blogsnapper

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘exclude post from main index’ is closed to new replies.