Home Forums Add-ons Flexible Content Field Modify flexible content block options on the fly


Modify flexible content block options on the fly

  • Hi,
    I’ve developed a pretty straightforward row / column pseudo page builder, that I’d like to use site-wide. I’ve got a set of ‘column types’, each a field group that is set to ‘inactive’, that I then display as clones to populate the add-a-column popup in each row. All good

    I now want to add some custom post type specific blocks to the popup, but only when the user is editing a post of that CPT.

    I’ve read the docs, and I can’t see a way to vary the options shown on the add popup, depending on the context the Flexible Content field is being edited.

    Any ideas?

  • Is it sub fields in a layout that you want to add or do you want you want to add additional layouts.

    If it is the latter, adding layouts, this would be done better by removing layouts. You would create these layouts and they would be part of the flex field. Then you would create an acf/load_field filter, loop over the layouts and keep them or remove them based on what is being edited. I posted an extremely basic example of doing this here

    Adding additional fields would be more problematic. In this case you’d need to add these fields using PHP Although, you could probably use the same removal method as above but you’d need to loop over all of the fields in each layout as well and remove them.

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

The topic ‘Modify flexible content block options on the fly’ is closed to new replies.