Home Forums ACF PRO Showing field group based on post category


Showing field group based on post category

    • Snow

    • June 13, 2019 at 4:59 am

    Hello, I am using WP 5.1.1 and ACF PRO 5.8.1.

    I’m trying to show a field group based on post category.

    If I do this using a location rule, then when editing a new post that has not been assigned the conditional category, I have to add the category, save the post, and refresh the page before the ACF fields show up. This is understandable behaviour but not very user-friendly.

    If I add a taxonomy field for the category, and a group field with conditional logic based on the taxonomy field, the behaviour is as desired. Toggling categories in the taxonomy field instantly toggles the group field on-the-fly. However, the problem is that the conditional logic for the taxonomy field does not have an option to set a specific value. Only “has any value”, “has no value”, “selection is greater than”, and “selection is less than”.

    What would be the best way to achieve what I want? Pointers to custom PHP/JS code are welcome.

    Thank you.

  • If you want to target a specific term you need to use

    value is greater than {TERM_ID-1} AND
    value is less then {TERM_ID+1}
    • Snow

    • June 15, 2019 at 3:56 am

    Hi, I don’t see “value is greater/less than” when I nominate a taxonomy field in the conditional logic. Only “selection is greater/less than”, which I had tried, and seemed to refer to the number of options selected rather than the value.

  • sorry, value == selection. It does not mean how many have been selected it is referring to the ID of the term that is selected.

    • Snow

    • June 15, 2019 at 4:10 am

    That is not how it appears to be working for me, though. For example selection > 0 and < 2 shows the group field when ANY 1 term is selected. Selection > 2 and < 4 shows the group field when ANY 3 terms are selected. Etc…

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.