Support

Account

Home Forums General Issues Several values (meta_value) for a UNIQUE custom field (meta_key)

Helping

Several values (meta_value) for a UNIQUE custom field (meta_key)

  • Hello everybody,
    Hope you are “building” site(s) well.

    I have a “simple” need but I struggle anyway. I have created a custom field for products. One product can have several values for this very same custom field.

    Here is an example:
    Let’s say this custom field is named “Health DISORDER”.
    Lets say than a product can help to fix “headache” and “neck pain” and even possibly “back pain”.
    Then I need to enter three values for this product. But for another it could be only one value of course.
    I simply don’t see how to do this with ACF.

    Fact is I don’t want to enter “headache, neck pain, back pain” as a unique value (unique string) because then, as you can imagine, I would like to sort the products out with just “headache” or “neck pain” or “back pain” value.
    And then for “headache” (for example) I will display a products list with products that JUST fix “headache” AND products that fix “headache” and something else.

    Hope I was clear enough.

    I would like to thank you in advance for any help on how to do this.
    Regards,
    Oxley

  • The best solution to this is not to use a custom field but to use custom taxonomy.

    For information on taxonomies see https://codex.wordpress.org/Taxonomies

    Create a custom taxonomy named “health-disorder” then create a term for each disorder. Then you can assign your products to one or more terms and this will allow sorting and display by the terms.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Several values (meta_value) for a UNIQUE custom field (meta_key)’ is closed to new replies.