Home › Forums › Feature Requests › Flexible content blocks – friendly/custom collapsed name › Reply To: Flexible content blocks – friendly/custom collapsed name
One idea to automate, for each layout you can start with a field labeled “Admin Title” and name it as “layout_title”, then you use this function on your theme functions.php
.
function my_layout_title($title, $field, $layout, $i) {
if($value = get_sub_field('layout_title')) {
return $value;
} else {
foreach($layout['sub_fields'] as $sub) {
if($sub['name'] == 'layout_title') {
$key = $sub['key'];
if(array_key_exists($i, $field['value']) && $value = $field['value'][$i][$key])
return $value;
}
}
}
return $title;
}
add_filter('acf/fields/flexible_content/layout_title', 'my_layout_title'), 10, 4);
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.