Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134580

jomsky on "How to customize wildcards using meta_query"

$
0
0

I'm trying to use the LIKE operator for the meta_query parameter but it seems that it automatically wraps "%" on the meta value.

An example:

'meta_query' => array(
                    array(
                        'key' => 'surname',
                        'compare' => 'LIKE',
                        'value' => 'ab'
                    )
                )

This functions as LIKE '%ab%' in the generated SQL.

What I want to do is only use wildcards AFTER the the meta value, so it should be: LIKE 'ab%'. I can't find a way to achieve this though, is there a built-in function for this that I missed somewhere? Or am I better off using a direct query to the database?

Thanks!


Viewing all articles
Browse latest Browse all 134580

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>