Support

Account

Home Forums General Issues Display Category only if it has Color

Helping

Display Category only if it has Color

  • Hey,

    This might sound complicated but I don’t think it’s that complicated.

    I have a list of WP Post Categories:
    – Category A
    – Category B
    – Category C
    New categories will be added in the future.

    I want to assign a color to A (red) and another color to C (blue), which is trivial.

    Next, I want to display a dropdown on all Posts that shows exclusively categories that have a color set. So in this case A and C, but not B (as it has no color previously assigned).

    How can I achieve this?

    Thank you,
    Razvan

  • To get a list of terms you would use get_terms(). get_terms() allows a meta_query, just like WP_Query(). You can use a meta_query to get terms where a field “EXIST” or is not empty (!= “”)

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

You must be logged in to reply to this topic.