[wp-trac] [WordPress Trac] #8619: category_name query fails for
multiple-word sub-categories
WordPress Trac
wp-trac at lists.automattic.com
Mon Dec 15 06:38:39 GMT 2008
#8619: category_name query fails for multiple-word sub-categories
----------------------+-----------------------------------------------------
Reporter: filosofo | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.8
Component: General | Version: 2.8
Severity: normal | Keywords: has-patch category_name query_posts get_category_by_path
----------------------+-----------------------------------------------------
Suppose you have a category named "I am sub category". Its URL looks
something like this:
{{{example.com/grandparent/parent/i-am-sub-category/}}}
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.
--
Ticket URL: <http://trac.wordpress.org/ticket/8619>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list