WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :


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.


share|improve this question
up vote 4 down vote accepted

your custom post type will likely work if you visit your permalinks page and save, which forces a flush of the rewrite rules. however, you probably won't be able to get the taxonomy to work using the same slug, custom post types seem to supersede taxonomies if they share a slug. anyway, it would probably be a big performance hit even if it did work, WP would have to generate a rewrite rule for every term or post you create, or look in two different places for every request.

also- your register_taxonomy should be wrapped in a function that gets called on init, like your recipes_register function.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.