I am experiencing problems with custom post types, taxonomies, permalinks and rewrites.
I created a custom "recipes" post type and taxonomy using this code:
add_action('init', 'recipes_register');
function recipes_register() {
$labels = array(
'name' => __('Recipes', 'framework'),
'singular_name' => __('Recipe', 'framework'),
'add_new' => __('Add Recipe', 'framework'),
'add_new_item' => __('Add New Recipe', 'framework'),
'edit_item' => __('Edit Recipe', 'framework'),
'new_item' => __('New Recipe', 'framework'),
'view_item' => __('View Recipe', 'framework'),
'search_items' => __('Search Recipe', 'framework'),
'not_found' => __('Nothing found', 'framework'),
'not_found_in_trash' => __('Nothing found in Trash', 'framework'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/img/admin-recipes.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => null,
'supports' => array('title','editor','thumbnail','comments'),
);
register_post_type( 'recipes' , $args );
}
register_taxonomy('recipe_type', array('recipes'), array('hierarchical' => true, 'label' => __('Recipe Type', 'framework'), 'rewrite' => array('hierarchical' => true, 'slug'=>'recipes')));
The problem occurs when I want to access to custom type post with this type of URL, it throws a 404 error :
http://my-website/recipes/name-of-the-recipe/
I think the problem is caused because I want to use the same slug for the taxonomy "recipe_type" and the "recipe" custom post type.
I am a bit stuck on this and I would be grateful if you could help me with this.
Thanks