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?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.