How can I search my database, in WordPress, for all the options of a custom field?

I’m in a custom taxonomy page and I need to display all the options of a particular custom field called “Region”. I tried doing a database query for all the possible values, however because multiple regions are selectable in the custom field, the resulted values are the many different combinations of regions (such as “Asia, Africa, Europe” as one, “Central America, North America” as another and “Europe, Central America”, etc etc.)

I want to retrieve just them just singularly, (“Asia” as one, “Europe” as another, etc. etc.) How would I go about doing this?

Related posts

1 comment

  1. You can use some basic coding approach of php.

    Approach:

    Use the explode() function of php and set the values in an array for each meta value with a key ‘coffee_region’ (adding each meta value in the a single array. Make sure you are adding elements not overwriting the previous values of meta in array).

    Then use array_unique() function to get rid of the repetitive countries from the array.

    And when you print that array you will be having a listing of unique country names from the meta fields

Comments are closed.