Recipes Docs

Taxonomies

This theme includes custom taxonomies for the recipes. The taxonomies work like the categories for normal blog posts. You can also register your own taxonomies, and they will work just like the built-in custom taxonomies.

Included taxonomies #

You can edit taxonomy terms by clicking Recipes → Taxonomy Name at the WordPress dashboard, for example Recipes → Courses.

When creating a new term or editing a term, you can set an image for it. Image is used on the template when viewing a single term. The recommended minimum size for the image is 1140 × 500.

Use the Description field to set a description for the term. The description is shown on the template when viewing a single term.

You can also set a term as featured. This is used for example in the widget listing terms where you can choose to display only featured terms.

Registering a custom taxonomy #

In addition to built-in taxonomies, you can also add your own taxonomies. Here's a code snippet demonstrating how to register a new taxonomy.

function my_custom_register_taxonomy() {

$labels = array(
'name' => __( 'Tests', 'recipes' ),
'singular_name' => __( 'Test', 'recipes' ),
'menu_name' => __( 'Tests', 'recipes' ),
'edit_item' => __( 'Edit Test', 'recipes' ),
'search_items' => __( 'Search Tests', 'recipes' ),
'not_found' => __( 'No test found', 'recipes' ),
'add_new_item' => __( 'Add New Test', 'recipes' ),
);

$args = array(
'label' => __( 'Test', 'recipes' ),
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'query_var' => 'test',
'show_admin_column' => true,
'rewrite' => array(
'slug' => 'test',
'with_front' => false,
),
);

register_taxonomy( 'test', 'recipe', $args );
}
add_action( 'init', 'my_custom_register_taxonomy' );

How you use the code snippet is up to you. One of the easiest ways is to use a plugin like Code Snippets.

Adding snippets straight to the theme files like functions.php is not recommended as you will lose all your changes once the theme is updated.

For more information please see the WordPress documentation about taxonomies.

After you have successfully inserted the code, the taxonomy should be visible at Recipes → Taxonomy Name. Now you should go to Settings → Permalinks, and click Save Changes. You don't have to change the anything, just save the settings. This clears the permalink structure of the site, and makes sure that the new taxonomy works correctly.

Now when you have registered the taxonomy, you can use it just like the built-in taxonomies. You can go to Recipes Options to choose if you like the taxonomy be shown on the recipe filters and front-end recipe submit form.

At Apperance → Customize → Recipes Theme you can select if your taxonomy is shown on the recipe cards.

Of course you must first have recipes using the new taxonomy, otherwise it won't be shown on the filters for example.