Support

Account

Home Forums Front-end Issues Multiple ID's in relationship field — LIKE query returns inappropriate posts Reply To: Multiple ID's in relationship field — LIKE query returns inappropriate posts

  • Hi @andrewmartin

    It shouldn’t match both 2 and 127 because it has extra double quotes there:

    '"' . get_the_ID() . '"'

    For example, if get_the_ID() returns 2, then the query would be like this:

    'value' => '"2"',

    Which will only match serialized string that has "2" in it like this:

    a:1:{i:0;s:1:"2";}

    And not this one:

    a:1:{i:0;s:3:"127";}

    Could you please test it again by providing the value manually like this:

    'meta_query' => array(
        array(
            'key' => 'location',
            'value' => '"2"',
            'compare' => 'LIKE'
        )
    ),

    Also, could you please check the database if there’s extra ID there?

    Thanks 🙂