Support

Account

Home Forums Add-ons Flexible Content Field Echo all flexible content field names in use on a page? Reply To: Echo all flexible content field names in use on a page?

  • Did you try using get_field_objects()?

    https://www.advancedcustomfields.com/resources/get_field_objects/

    You could use a conditional to grab only Flexible Content fields:

    
    <?php 
    if ($field['type'] == 'flexible_content') { // not sure if this is correct 
    
    /*
    *  get all custom fields and dump for testing
    */
    
    $fields = get_field_objects();
    var_dump( $fields ); 
    
    /*
    *  get all custom fields, loop through them and create a label => value markup
    */
    
    $fields = get_field_objects();
    
    if( $fields )
    {
    	foreach( $fields as $field_name => $field )
    	{
    		echo '<div>';
    			echo '<h3>' . $field['label'] . '</h3>';
    			echo $field['value'];
    		echo '</div>';
    	}
    }
    
    } 
    ?>
    

    More here: https://support.advancedcustomfields.com/forums/topic/if-statement-based-on-field-type/

    Does this help?