I'm running a standard WP_Query on a property website, and I want to find all properties that have a postcode beginning with 'SC1'. In the meta query, doing a normal LIKE on the postcode works, but it also returns properties with postcode SC13, which isn't what I want.
As a result, I've changed my meta query to be as follows:
array( 'key' => '_address_postcode', 'value' => 'SC1 ', // Notice the addition of the space 'compare' => 'LIKE' )
However.. it's not working. I've dug deeper and it seems that WordPress is trimming the values:
Any idea how I can search for meta values that specifically have a space at the end? I thought of doing something like so:
array( 'key' => '_address_postcode', 'value' => 'SC1 %',// Add a space then wildcard 'compare' => 'LIKE' )
... but that doesn't work. Can anyone think of a way to get around this :-S