Support » Fixing WordPress » Same name for custom post and custom taxonomy

  • I have a problem since I have upgraded my WordPress from 3.0 to 3.1
    I used custom posts and custom taxonomies. Some of them have the same name.
    For example I have a custom post named “theme” and a custom taxonomy named “theme” too 😉
    I don’t think it is not allowed. (?)

    if it is “not allowed” close my post 🙂

    In the admin if you use this URL:
    You should have a list of all custom posts “illustrations” in the “brand-positioning” which is a term of “theme” taxonomy.
    It does not work since 3.1
    If you try something similar you will have “No posts found.”

    The problem comes from these lines in /wp-includes/class-wp.php (function parse_request):

    if ( isset($post_type_query_vars[$wpvar] )) {
    					$this->query_vars['post_type'] = $post_type_query_vars[$wpvar];
    					$this->query_vars['name'] = $this->query_vars[$wpvar];

    So here the code thinks “theme” is a post type and add to the query “name” => “brand-positioning”.
    It is like the deprecated ‘my_taxonomy’ => ‘my_term’
    ( see )
    I don’t think that ‘my_custom_post_name’ => ‘my_post_name’ is documented.

    It worked in WP 3.0 because the feature “‘my_taxonomy’ => ‘my_term'” was not removed and the code above was testing if the taxonomy existed before the custom post. (So I was lucky…)

    I don’t know if it the code above should not be there or if the URL should have others parameters.

    Thanks for any response.

Viewing 2 replies - 1 through 2 (of 2 total)
  • evandavidpaul


    I have gotten myself in a similar situation. I deliberately named a custom tax the same thing as a custom post_type and was using the posts that had the assigned custom tax to pull information from the corresponding custom post_type. This part worked great, but now I would like to display the custom post type itself.

    If i just click “view post” from the edit screen it gives me a 404.

    What is the rule we are breaking here? are their workarounds?



    2 things:
    * for “I would like to display the custom post type”
    You are going to have 2 similar URLs. If you want to have both accessible you need to have 2 real different permalinks.
    You can play for example with “with_front” parameter of “register_taxonomy”. See
    You have also similar things with “register_post_type”
    It seems that if you have a permalink structure like “/%category%/%postname%/”:
    “/myCustomTaxonomy/myTermSlug/” will override “/myCustomPostType/myPostName” (with myCustomTaxonomy == myCustomPostType && myTermSlug == myPostName)

    * for 404 check :

    I hope it will help you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Same name for custom post and custom taxonomy’ is closed to new replies.