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:
/wp-admin/edit.php?theme=brand-positioning&post_type=illustration
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 https://codex.www.ads-software.com/Function_Reference/WP_Query#Taxonomy_Parameters )
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.
- The topic ‘Same name for custom post and custom taxonomy’ is closed to new replies.