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’re working hard on Advanced Custom Fields PRO 6.0, and Beta 1 is now available 🚀
— Advanced Custom Fields (@wp_acf) August 12, 2022
Featuring improved performance for Repeater fields with large datasets, and a new generation of ACF Blocks.
Let’s take a look 🧵https://t.co/Befre3kFAo
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.