I’ve just tested your code like the following on my end, and it has the leading ‘%’ in the query.
$zip = 123456; $EXTRA = array( 'key' => 'mailing_zip', 'value' => $zip, 'compare' => 'LIKE' ); $EXTRA['relation'] = 'OR'; $EXTRA = array( 'key' => 'locator_address', 'value' => $zip, 'compare' => 'LIKE' ); $meta_query = new WP_Meta_Query(); $meta_query->parse_query_vars( array( 'meta_query' => $EXTRA ) ); $mq_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID', null ); print_r($mq_sql);
Maybe there’s a custom function in your installation that modifies the query. Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Fifteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.
Also, I believe this question is more related to WordPress than ACF. For further support, could you please ask it in the WordPress support forum?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.