• Leo

    (@wp_new_user)


    Hello,

    In my posts I have a custom field ‘country‘ the value of which is something like this ‘spain,italy,france,germany‘ – a comma- separated list of country names.
    I need to filter my posts by countries, so when ‘spain’ is selected I need to show posts that have ‘spain’ in the value of the ‘country’ meta key.
    Is there any way to have the query that will make this happen without having separate custom fields for each country?

    array(
        'key'            => 'country',
        'value'         => $country,
        'compare'   => WHAT NEEDS TO BE HERE?
    ),

    Now on post update I add separate custom fields for each country and get their values from the ‘country’ field, it works, but I have more than 100 fields and I update them often, so was thinking maybe there’s another better option?

    Thank you.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘WP_Query Custom Filed Parameters’ is closed to new replies.