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:
(there are several plugins doing it…)
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.
For excluding posts in the Recent Posts list, check out this 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…
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; ?>
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
- The topic ‘exclude post from main index’ is closed to new replies.