0

I'm just beginning the build on a site which has long-form pages broken up into multiple sections. Each section should follow one of a limited number of formats - e.g. 3 column, 2 column, full-width, quote etc.

I'd like to use the Advanced Custom Fields plugin to try and constrain how users enter the content so they can add similar pages in future without needing customisation from me.

I can think of two ways of solving this:

  1. I write a custom query which loops through all the sub-pages of the current one, then based on the template selected for the sub-page use get_template_part to pull in page content along with the relevant ACF fields.
  2. I use the ACF flexible content plugin to define the entire page in sections.

I've not used flexible content on ACF before - so I'd love to know whether anyone has learned from experience any performace or usability drawbacks to either approach?

1

This is a pretty open-ended question. And I'm not sure I fully understand what you're shooting for. You could go about this any number of ways. Whichever way you choose will ultimately depend on you weighing the pros and cons of each and how your client will want to be in control of the layouts. I see three viable solutions for your case.

Apply conditional logic to the fields themselves:

ACF allows for conditional logic on its fields. It allows you to create multiple sets of fields that will show depending on the values of other fields. Simply create fields that will control the visibility of other fieldsets. You can view this by expanding a custom field from the edit page and checking the box near the bottom of the field "Enable conditional logic". This way the content manager will be able to "create" the layout of the post/page based on a series of radio buttons or checkboxes (that control the conditional logic) as they are drafting the post/page.

Apply logic rules to the field groups:

You can also apply field groups to post templates, categories, custom taxonomies, etc ("Rules:" located near the bottom of the edit field group page). If you want to create different field groups for your client to choose from as they create new posts/pages, you can have them add the post/page to a category or custom taxonomy -- which will then pull up the correct field group for the post/page. This will allow a certain pre-defined set of variations that you will need to create with ACF. The content manager would merely select which layout to use (less flexible than applying logic to the fields themselves).

Use Flexible fields:

I really like flexible fields. It would be my preferred approach if you have the extension. This is basically a combination of the two previous approaches in terms of content management/flexibility. You could create field sets that are not so flexible for the content manager (make, say 3 different options each containing some number of fields), or you could create a flexible field for every type of field (which would allow the content manager to "build" and arrange the fields and their order to their liking). Also, flexible fields is exrtemely intuitive and probably the easiest solution for your content managers to grasp. You can find the code to display the flexible fields from the ACF website. It's all pretty straightforward.

Hope this helps!

edit: I would rule out your first solution. The less queries, the better. No need to bog your server down with extra requests when the functionality is built right into the plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.