category_name query fails for multiple-word sub-categories
|Reported by:||filosofo||Owned by:||ryan|
|Component:||General||Keywords:||has-patch tested category_name query_posts get_category_by_path|
Suppose you have a category named "I am sub category". Its URL looks something like this:
When you query for the sub-category using category_name, like so
query_posts(array('category_name' => 'I am sub category'));
the query calls get_category_by_path() on 'I am sub category' first with the default of "full match" set to true, which returns null because the full match would include the parent and grandparent category names, as above.
By the time the query gets around to calling get_category_by_path() again, this time with full match set to false, it has stripped the spaces from it, so that it searches for 'iamsubcategory' which it won't find.
The solution is to sanitize the category name from the start so the spaces are handled correctly.
Change History (9)
- Keywords has-patch tested added; needs-patch removed
- Owner changed from anonymous to ryan
- Status changed from reopened to new