[wp-trac] [WordPress Trac] #27810: wp_query taxonomy query by name doesn't seem to work if there's a space in the name
WordPress Trac
noreply at wordpress.org
Fri Feb 6 01:57:10 UTC 2015
#27810: wp_query taxonomy query by name doesn't seem to work if there's a space in
the name
--------------------------+-----------------------
Reporter: neonWired | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 4.2
Component: Taxonomy | Version: 3.9
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+-----------------------
Changes (by boonebgorges):
* component: Query => Taxonomy
* milestone: => 4.2
Comment:
It's not invalid. I've confirmed the bug. The issue is that the type of
sanitization that's taking place in `WP_Tax_Query` does not match the type
of sanitization that happens when terms are inserted into the database. In
this particular case, that means that `Foo Bar Baz` is being turned into
`foo-bar-baz` for the `WHERE` clause.
> If query is by name and the string is not numeric, pass it to
sanitize_title() and then run the query by slug. That'll work in every
case except where there are duplicate names (and in that case, one cannot
complain).
No, because it's possible to create a term with a `name` that is totally
unrelated to the `slug`. The correct fix is to use `sanitize_term_field()`
instead of `sanitize_title_for_query()` inside of
`WP_Tax_Query::transform_query()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27810#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list