Sometimes I want WordPress posts to be easily accessible, but not advertised in public. When I have a story to share with my mother, I just want to send her the direct link - but I don’t want the post to appear on the home page or be reachable via navigation links or feeds.
WordPress has functionality to allow posts to be ‘Private’ or ‘Protected’, but both of these require passwords or logins. This is more than I want to subject my mother to.
So I have created a patch to WordPress 2.7, which adds functionality to hide certain categories and all the posts in those categories. This patch does the following:
- Allows you to set the ‘hidden’ flag on any category in the Admin GUI.
- Hides any hidden categories from the category list in the sidebar.
- Hides ‘previous’ and ‘next’ links to a post in a hidden category (when viewing a single post).
- Hides the post from the RSS2 feed.
- Hides the post from your front page (minor theme modification required).
Download the patch here (17KB)
Applying the patch
First, make a backup. This patch is provided in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you are applying this patch to an existing WordPress installation, you will need to make a minor database modification:
ALTER TABLE wp_terms ADD COLUMN flags VARCHAR(100) DEFAULT '';
Next, apply the patch. This example assumes the patch is located in your home directory (~).
user@host:~$ cd /path/to/wordpress
user@host:/path/to/wordpress$ patch -p1 < ~/wp2.7-hidden-categories.diff
Finally, change your blog template. Locate the beginning of The Loop and add the line in bold:
<?php while (have_posts()) : the_post(); ?>
<?php if ( is_hidden_category() ) continue; ?>
That’s it! You can now go into the admin GUI and set any category to ‘hidden’ via Posts > Categories.
Alternatives
Would like this functionality but don’t want to patch your WordPress? Have a look at the following plugins:
These are easier to install but do not hide previous/next post links and do not hide the categories from the category listing in the sidebar. I believe this is impossible within the current plugin architecture (but please let me know if I’m mistaken).





