I’m using WP_Query
to retrieve posts based on certain taxonomy terms. The problem is that WP_Query
is not returning any results if the term has a single quote.
Here’s the relevant portion of the args passed to WP_Query:
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => country
[field] => name
[terms] => Array
(
[0] => People's Republic of China
)
)
)
I tried escaping the quote (e.g. People's Republic of China)
but still there are no results.
There is no problem with the code as other terms without the quote work. And if you ask, there are posts with the single quotes as validated from directly querying from the database (via phpmyadmin).
I know that I can just query using taxonomy id and slug (e.g. 'field'=>'term_id'
AND 'field'=>'slug'
) but I hope not to as too may code has been written to use the term name.
Thanks