Ultimate Web Tips
your Wordpress, jQuery, PHP, MySQL, Linux and CSS guide to a successful website
Read more:

August 2nd, 2011

WordPress 3.0 guide to custom taxonomies

Themes, by Joakim Ling.

Taxonomies are used to group, classify and order posts in WordPress. You are probably familiar with tags och categories that are default taxonomies in WordPress.

Since WordPress 3.0 theme developers are now able to add their own custom taxonomies, usually done in functions.php in the theme folder.

How to add custom taxonomies

It’s very simple to add, use the register_taxonomy function. Here is a short snippet to add “Color” as a taxonomy to posts.

register_taxonomy('color', 'post', array('hierarchical' => false,  'label' => 'color','query_var' => true, 'rewrite' => true));

When this is done you will see a new menu item in Posts menu called Color where you can add colors and tag them in to your posts same way as with tags.

How to use it

To show the colors tags to your post you just add the snippet below to make it appear as post tags and categories in your loop.

<?php echo get_the_term_list($post->ID, 'color', 'Colors: ', ', ', ''); ?>

You can register how many taxonomies as you like and add to your custom post types as well. There is no limit of how you can organize your content.

Wordpress Salesletter Websites Creator

This unique software is a wordpress theme that users can create professional salesletters as well as it has the option to expand their site to add a blog, contact us page, Affiliate pages and hundreds more. Download theme

Back Top

Club World Casinos