WordPress Custom taxonomies

May 6th, 2010 |

It’s a small article that’s answer for question about “How I can add a custom taxonomies for posts in WordPress”. This feature was added in WordPress 2.8.

1. Registration

More information on codex.wordpress.org.

register_taxonomy('employment', 'post',
                          'hierarchical' => true, 'label' => 'Employment Process',
                          'query_var' => true, 'rewrite' => true));

2. Using …

…to create a tag cloud of your custom taxonomies:
wp_tag_cloud( array('taxonomy' => 'employment', 'number' => 45) );
…to list a taxonomy’s terms for some post (comma separated):
echo get_the_term_list( get_the_ID(), 'employment', 'Employment: ', ', ', '' );
…to select posts from a specific taxonomy:
query_posts( array('employment' => 'termination', 'showposts' => 10) );

It’s all, have you any questions? 😉

There are no comments yet

Leave a Reply

Your email address will not be published. Required fields are marked *