Flexible Content Fields in Field Manager

Field Manager doesn’t have a flexible content field type as Advanced Custom Fields Pro does, but it is possible to mimic the functionality by using a little logic.

First, we need a parent field group, which is repeatable so we can add multiple content sections, and sortable so we can rearrange the content sections by dragging and dropping them:

To this field group, we’ll add a select field. This select field will later be populated with the names of all our flexible content fields’ labels, so we can select which type of content section we want to use:

Next, we’ll initialize an array, which will hold all of our flexible content fields – or field groups as they really are:

Now, we can add as many regular field groups as we like to this array:

After we have added all our field groups to the flexible content field array, we’ll loop through it to add the field groups name/labels to the select field, modify the field groups to only show if they are selected in the select field and finally add them to the parent field group:

If you edit a post now, you should have a metabox where you can add content sections and select the content type you want to show:

Select a flexible content field type.
Select a flexible content field type …
… and the field group for the content type will show.

Here is the full code which mimics an ACF flexible content field in Field Manager. This code also add a title field for each section, and a section which shows all the fields available from Field Manager:

A final warning

Even though the fields from the inactive field groups aren’t visible – they’re still there, unlike the real flexible content fields in ACF Pro. This means that if you are a heavy flexible content user, you might run into scaling issues. Many times I’ve seen sites with ~15 different flexible content fields and pages which use way more that 15 content sections. If those flexible content fields have 5 data fields on average, you’ll end up with more than 1350 data fields in total. Field Manager will then store all those data fields in a single serialized field in the postmeta table.

There are no comments

I love comments that bring new insights, shares ideas and experiences, and most of all: corrects my mistakes. For support questions, there are other fora, like Stack Overflow, Server Fault and the WordPress support forum.

Your email address will not be published. Required fields are marked *