Home Forums Add-ons Flexible Content Field Conditional display of field, if options page?


Conditional display of field, if options page?

  • Hello there!

    I’m using flexible content to display a couple of layouts but I’m also made a clone of this flexible content to use in an options page. The reason for this is that I have some layouts that I want to include in the footer on every page. This is working perfectly.

    For the options page:
    What I’m trying to achieve right now is some kind of function where I can select which layouts are visible in the footer on certain pages.

    I thought about using a true/false-field to achieve that (Like ‘Only display on front page’), but then that field will be visible in the regular flexible content for the pages since I can’t have display conditions for a field based on if its from an options page, and then it simply isn’t good enough.

    Do anybody have a suggestion of how I could solve this?

  • Add the fields. Use an acf/prepare_field filter. Use the field key variation. Remove the field (return false) if and options page is not being edited. In your filter use WP function get_current_screen() to see what is being shown in the admin do decide if the field should be removed or not.

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

You must be logged in to reply to this topic.