1. Create template.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php /** * Template Name: Flexible */ get_header(); ?> <?php if( have_rows('flexible_content') ): while ( have_rows('flexible_content') ) : the_row(); get_template_part( 'template-parts/block', get_row_layout() ); endwhile; endif; ?> <?php get_footer(); ?> |
2. Install Advanced Custom Fields PRO.
3. Create Field Group for define template.
4. Add layout (e.g., content).
5. Create template for each layouts.
1 2 3 4 5 6 7 8 9 10 |
<?php $width = empty( $class = get_sub_field( 'class' ) ) ? '_s' : $width; $class = empty( $width = get_sub_field( 'width' ) ) ? 'content' : $class; ?> <section class="<?php echo $class; ?>"> <div class="container <?php echo $width; ?>"> <?php echo apply_filters( 'the_content', get_sub_field( 'content' ) ); ?> </div> </section> |