Tutorials, Wordpress

How to use ACF flexible content fields?

28 January 2019

The ACF flexible content field is essential a wrapper for a group of layouts, so to loop through the layouts and target the sub field values, you must make use of a few extra functions.

Basic loop example :

// check if the flexible content field has rows of data
if( have_rows('flexible_content_field_name') ):

     // loop through the rows of data
    while ( have_rows('flexible_content_field_name') ) : the_row();

        if( get_row_layout() == 'paragraph' ):


        elseif( get_row_layout() == 'download' ): 

        	$file = get_sub_field('file');



else :

    // no layouts found


Output here:

Drag and drop a section

Leave a Comments