[wp-hackers] [PATCH] New feature: 'Hidden' categories

Pascal Haakmat a.haakmat at chello.nl
Tue Dec 30 14:40:24 GMT 2008


Greetings,

Thanks for WordPress. I've been using it for a few weeks now and
love working with it.

I have created a patch for WordPress 2.7 which adds the ability to
create "hidden" categories and would like to invite your comments and
criticisms on both idea and implementation. I have not done any 
research on prior or similar work so please forgive me if I have
overlooked anything.

PURPOSE
=======

I often want posts to be easily accessible, but not advertised in
public. Sometimes I just want to be able to create a post and send the
direct link to my mother. WordPress has functionality to allow posts
to be 'Private' or 'Protected', but both of these require the viewer
to supply credentials. This is more than I want to subject my mother
to. 

I want to stress this is not a method to protect or secure posts. It
is instead a way to organize posts so that they don't clutter up the
main 'flow' and aren't exposed to casual viewers.

IMPLEMENTATION
==============

I have attached a patch implementing this functionality. The patch is
against WordPress 2.7.  

The patch modifies the database schema to add a 'flags' column to the
wp_terms table. The flags column is a comma separated list of string
values. Only the 'hidden' flag is defined. (this could be done more
efficiently using the MySQL enum type but I did not want to assume a
specific database)

The Walker_Category class was modified to test for the hidden flag and
not output anything if it exists.

The admin UI was modified to add a checkbox that allows setting the
hidden flag when creating or editing a category.

The following line of code needs to be added to The Loop of themes:

                <?php while (have_posts()) : the_post(); ?>
		<?php     if ( is_hidden_category() ) continue; ?>

This line of code was also added to the feed-rss2.php.

I welcome your comments and insights.

Have a fine 2009! 

Pascal.



More information about the wp-hackers mailing list