Created
February 13, 2017 10:59
-
-
Save asha23/fb622c50195a34e3303ec467db9de139 to your computer and use it in GitHub Desktop.
Advanced Custom Fields Flexible Content Type Rename Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for putting this together! Got me out of trouble.