Have you found that you have thousands of tags that are unmanageable? Have you dreamed you could somehow start over?
Well today you can thanks to custom WordPress Taxonomies. Taxon-what? A Taxonomy is just a fancy word that represents a way you can better sort your posts, pages and links in WordPress.
In this WordPress Video Tutorial you’ll find out everything you ever wanted to know about WordPress Taxonomies and more.
Here I’ll create a custom Taxonomy that will contain only tags that would commonly be used as ingredients for a recipe.
After you create this new taxonomy it will show up just like Categories and Tags do on your dashboard. You can then create custom tags of your choosing also in the same ways as Categories and Tags.
The interface is also identical as you see here.
Creating WordPress Taxonomies
You might think that it must be terribly hard to create custom WordPress Taxonomies, but like most things in WordPress it is very simple.
Just open the functions.php file that is in your WordPress Theme and type the following at the bottom of the file.
add_action( ‘init’, ‘create_ingredient_taxonomy’, 0);
function create_ingredient_taxonomy()
{
register_taxonomy ( ‘ingredients’, ‘post’, array( ‘hierarchical’ => true, ‘label’ => ‘Ingredients’, ‘query_var’ => true, ‘rewrite’ => true ) );
}
The add_action() function tells WordPress to run the function named create_ingredient_taxonomy as soon as WordPress has been initialized or loaded.
The 0 attribute tells WordPress that this action is of the highest priority. The larger that number is, the less important it is.
I’ll cover this subject in more detail when I teach you to create custom plugins and widgets.
Then when the function create_ingredient_taxonomy is called the following function is called:
register_taxonomy ( ‘ingredients’, ‘post’, array( ‘hierarchical’ => true, ‘label’ => ‘Ingredients’, ‘query_var’ => true, ‘rewrite’ => true ) );
Here is what it means:
That’s all you need to do to add this nice feature to your WordPress website.
WordPress Tag Clouds and Taxonomies
In the above video I also talked about the code needed to display tag clouds of your taxonomies in WordPress. Here it is
<?php wp_tag_cloud( array (‘taxonomy’ => ‘ingredients’, ‘smallest’ => 7, ‘largest’ => 20, ‘unit’ => ‘pt’, ‘number’ => 40 )); ?>
The above code will call and display a tag cloud using your custom taxonomy.
I hope that helps you to better organize your data inside of WordPress.
I’ll be covering plugins and widgets very soon. Leave any questions or comments below.
Till Next Time
Thanks a lot for your brilliant tutorials on building wordpress themes. I feel really capable now to try it out myself.
You’re very welcome. I’m glad you liked them. I organized most everyone of them on one page WordPress How To. Sorry about the disorganization