You have to build a website for a restaurant and you have chosen WordPress to do the job. It’s time to add restaurant’s products but you have to classify them. Well there’s a very easy way to do that.
What products does a restaurant have? Well, I think a regular restaurant has Breakfast, Launch, Dinner, Beverage and Dessert.
Open functions.php from your wordpress theme directory and add the following code:
function create_menu_categories() {
register_taxonomy(‘menu_type’, ‘post’, array(‘hierarchical’=>;false, ‘label’=>’Menu type’, ‘query_var’=>true, ‘rewrite’=>true));
}
add_action(‘init’, ‘create_menu_categories’, 0);
Query for posts, using custom tag
To display only posts that have a specific tag from your custom taxonomies, place the code before the loop:
<?php query_posts(array('menu_type' => 'dessert', 'showposts' => 10)); ?>
You can change dessert to any other tag listed in the custom taxonomies and you can change, of course, how many posts to show by changing the number 10 to your number.










