Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic MetaBox doesn't saves and it doesn't work with selected category Reply To: MetaBox doesn't saves and it doesn't work with selected category

#9310

Anh Tran
Keymaster

Hi,

There are several things in this case:

  1. I see you create 2 groups: 1 group for categories A & B, 1 group for categories C & D. And you put the conditions in each fields of the groups. That’s not good for performance because the plugin has to process all fields. Why don’t we put the conditions for the groups only? So we need only 2 conditions instead of 10?
  2. The value for the category select actually is the category ID, so we have to use IDs instead of category slug or name.

  3. The category select has a field type checkbox_tree, which means its value is an array. We can’t use operator = in this case. Instead, use contains.

I have adapted your code and made a fix here (please change the categories’ IDs to match your case):

https://pastebin.com/prL8r3Ra

Here is my test:

View post on imgur.com