I use the flexible content field for my pages, basically like a pagebuilder. However, with multiple rows, it can be confusing which is which especially when row types are repeated (image provided). I would love to feature the title on these blocks.
I have found this code, but my only issue is that not all of my subfields are just named “title”. However, they are like “twi_title” or “tb_title”. (The prefixes are named based on what I named the flexible block row.) Is there a way to get the sub field if it just includes “_title” or another way around this?
add_filter('acf/fields/flexible_content/layout_title', function($title) {
$ret = $title;
if ($custom_title = get_sub_field('title')) {
$ret = sprintf('<strong>%s</strong> <em style="font-size: 80%; opacity: 0.5">%s</em>', $custom_title, $title);
}
return $ret;
});
No, there isn’t any way around using the full field name.
I realize that it probably do late but there really is no reason to prefix every sub field of a repeater. Overall it just makes all coding more difficult.
Given what you have you will also need to use get_row_layout(), I’m pretty sure you can us that function in the filter.