[province] => Array ( [0] => a:1:{i:0;s:2:"FL";} )
We're using magic fields and I want to do a meta_query on the above, but it doesn't work.
$query = new WP_Query(array(
'post_type' => 'location',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
array('key' => 'province', 'value' => 'FL', 'compare' => 'LIKE')
)
));
How do I make it work? It returns nothing when I do 'CA' for instance when it should return two. It works with fields that are not encrypted. Is there a trick to this?
FLA
ORLFL
. You will need to modify your save code to prevent serialisation so that onlyCA
gets stored, notarray( "CA" )
CA
in a taxonomy calledprovince
?meta_query
is particularly slow as the post meta table wasn't designed for searches, so this query will get more and more expensive as you add more posts and meta values. A custom province taxonomy fixes that, and even gives you archives and templates for free as well as other things that can be turned off if you don't want them