Custom Fields
Support Meta Box Builder Using Conditional Logic with Taxonomies

  • Creator
  • #13489
    Resolved Alex Mansfield

    As far as I can tell (although I hope I'm wrong), it looks like meta boxes can be shown/hidden based on the value of a custom field, but not based on whether or not the post has a particular taxonomy term. Is that correct? I think I read about a way to do this with code, but I was really hoping to be able to do it from the Builder plugin. Is that possible?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
  • #13529
    Anh Tran

    Hi Alex,

    The Builder lacks of supporting for taxonomies for Conditional Logic at the moment. You can do that with Custom Attributes in the Advanced tabs. The attributes can be found in docs of Conditional Logic docs here:

    Mark Tenney

    Anh, I have tried this, but it only seems to work if a taxonomy has been selected and saved to the post. I have been trying to show fields based on the selection of a taxonomy_advanced field before saving the post with no luck.

    Anh Tran

    Hi Mark,

    For taxonomy_advanced field, it works similar to any other field.

    You can use contains or in condition and both works. Remember to use term ID to specify the value.

    So, you can write the condition like this:

    'visible' => ['field_id', 'contains', 4], // 4 is the term ID


    'visible' => ['field_id', 'in', [4, 2]], // 4, 2 are term IDs. In this case, the field will be visible if the tax_advanced has any term with the ID specified.

    Please see this video for demo:


    Hopefully we see a more visual way to select taxonomy terms (like hierarchical).


    I need this feature too. Any update as to if it will be coming to Builder anytime soon?

    Alex Mansfield

    After almost a two year break, I'm trying to figure this out again. In Ahn's initial reply, he said to use "Custom Attributes" in the "Advanced" tab. I've tried to do that, but I think something is wrong. My custom taxonomy is called "Plugin Category" with a slug of "plugin-category". I'm trying to display this meta box any time the "Plugin Category" is set to "Image Optimization" (slug for that term is "image-optimization").

    First, I tried this custom attribute:
    hidden > ['slug:tax_input[plugin-category]', '!=', 'image-optimization']

    Sadly, that hid the meta box everywhere, even if the post was part of the image-optimization plugin category.

    Next, I tried these custom attributes (as mentioned here:
    tax_query.0.taxonomy > plugin-category
    tax_query.0.field > slug
    tax_query.0.terms > image-optimization

    That didn't seem to have any effect. What am I doing wrong?

    Long Nguyen

    Hi Alex,

    I recommend using the field taxonomy or taxonomy_advanced to select a taxonomy for the post and show/hide another meta box base on the field value. See my screen record

    Alex Mansfield

    Thanks for the screen recording. I had tried that, but I didn't get it set up quite right. I think maybe I had used "=" instead of "in" as the comparison operator when I tried before. It's working now. Thanks for the help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.