Blog

ACF flexible content: a practical guide.

How to plan, build and render editable page sections in WordPress with Advanced Custom Fields.

By Leke Cermjani · Published

ACF flexible content is a field type in Advanced Custom Fields that lets editors build a page from a list of predefined layouts, such as a hero, a text block or a gallery, in any order. Developers design and code each layout once; editors then mix and reorder them without touching code.

What is ACF flexible content?

Flexible Content is an ACF Pro field. It holds a set of layouts, and each layout has its own sub-fields. On the edit screen, editors click "Add row", pick a layout and fill in its fields. The theme then renders each row with a matching template.

Plan your layouts first

Before creating fields, list the sections that appear across the design and group similar ones. A marketing site might use layouts such as:

  • Hero (heading, text, image, buttons)
  • Text and image (with an image-left or image-right option)
  • Card grid
  • Testimonials
  • FAQ
  • Call to action

Fewer, well-designed layouts with a few options are easier to maintain than many near-duplicates.

Build the field group

  1. In WordPress, go to ACF → Field Groups and add a new group, for example "Page sections".
  2. Add a field of type Flexible Content named sections.
  3. Add one layout per section type, with a clear label and a short name such as hero or text_image.
  4. Add sub-fields to each layout.
  5. Set the location rule to the page templates that should use it.

Render the layouts in your theme

Keep one template part per layout so each section stays easy to find and edit:

<?php if ( have_rows( 'sections' ) ) :
  while ( have_rows( 'sections' ) ) : the_row();
    get_template_part( 'template-parts/sections/' . get_row_layout() );
  endwhile;
endif; ?>

Then create template-parts/sections/hero.php, text_image.php and so on. Inside each, read sub-fields with get_sub_field() and escape output with functions such as esc_html() and esc_url().

Tips for editors and performance

  • Name layouts the way editors talk. "Testimonials" beats "Quote slider v2".
  • Customize row titles with the acf/fields/flexible_content/layout_title filter so collapsed rows on long pages are easy to scan.
  • Load assets per section where you can, so a slider script only loads on pages that use the slider.
  • Keep heading levels consistent. Give the hero the page's only H1 and use H2s for section titles.
  • Consider ACF blocks if your editors prefer Gutenberg. The same layouts can be registered as blocks.

Need flexible content set up on your site? See custom WordPress theme development.

Leke Cermjani

Leke Cermjani is a web developer in Pristina, Kosovo, building custom WordPress themes, ACF-powered sites and WooCommerce stores since 2020. More about Leke

Have a site in mind? Let’s talk.