Loading...

what is a taxonomy?

faisal / Wordpress

In WordPress, a “taxonomy” is a grouping mechanism for some posts (or links or custom post types). WordPress has three built in taxonomies that you’ve probably used already which are Category, Tags, Linked-category

For example, suppose you have a post type of “RECIPES”, then you can create a seperate taxonomy naming as “Levels of difficulty” and add different levels of difficulty in recipe makings! Let’s get started.

function create_recipe_taxonomy(){

                         register_taxonomy(‘difficulty’,’post’,array(

                                            ‘label’ => ‘difficulty’,

                                           ‘hierarchical’ => true,

                                          ‘query_var’ =>true,

                                        ‘rewrite’ => array(‘slug’ => ‘difficulty’

                  ));

               }