Support

Account

Home Forums General Issues Create meta_query with relationship field? Reply To: Create meta_query with relationship field?

  • Just came across this answer and thought it best to point out the the example above would cause issues with an id that has 16 in as it would match 116,161,1216, etc. and so the quotes around the value are important as per the comment.

    So…

    
    $args = array (
        'meta_query' => array(
            array(
                'key' => 'bedrijf', // name of custom field
                'value' => '"16"', // matches exaclty "16", not just 161. This prevents a match for "1234"
                'compare' => 'LIKE'
            )
        )
    );