Flexible Content lets editors build a page from sections (called layouts) in any order: a hero, then a text block, then a call to action, and so on.
Set it up:
- Add a field of type Flexible Content, labelled for example Page sections.
- Each layout has a label, a name, its own sub fields and a display style. Add layouts such as Hero (title, image), Text block (WYSIWYG) and Call to action (text, link).
- Optional: a minimum and maximum per layout, and a button label ("Add section").
As an editor:
- Click Add section and pick a layout.
- Drag sections to reorder them, and duplicate or remove them from the section's header.
- Rename a section (the pencil button) to give it your own label, such as "Spring sale banner". Press Enter to keep the name or Escape to cancel. The layout type stays visible next to it.
- Disable a section (the eye button) to hide it on the site without deleting it. It is marked Disabled and greyed out. Click again to turn it back on.
In a template:
<?php while ( sgcf_have_rows( 'page_sections' ) ) : sgcf_the_row(); ?>
<?php if ( 'hero' === sgcf_get_row_layout() ) : ?>
<h1><?php sgcf_the_sub_field( 'title' ); ?></h1>
<?php elseif ( 'text_block' === sgcf_get_row_layout() ) : ?>
<?php sgcf_the_sub_field( 'text' ); ?>
<?php endif; ?>
<?php endwhile; ?>
Disabled sections are skipped automatically.
