Skip to content

Instantly share code, notes, and snippets.

@yratof
Last active March 15, 2016 09:48
Show Gist options
  • Save yratof/fb44bcd7a743c177b039 to your computer and use it in GitHub Desktop.
Save yratof/fb44bcd7a743c177b039 to your computer and use it in GitHub Desktop.
ACF: Add a field name to the title of the flex field for easier management
<script type="text/javascript" defer="defer">
( function( $ ) {
acf.add_action('load', function( $el ){
$( 'div.values > [data-layout="product_category"]' ).each( function(){
var $name = $( '[data-name="menu_item_name"] input[type="text"]', $( this ) );
var $fallback = $( '.select2-chosen', $( this ) );
$name = $name.clone().val();
$fallback = $fallback.clone().text();
$name = $name + ' / ' + $fallback;
var $title = $( '.acf-fc-layout-handle', $( this ) );
var $strong = $( '<strong>' );
$strong.append( $name );
$strong.appendTo( $title );
});
});
} ( jQuery ) );
</script>
@yratof
Copy link
Author

yratof commented Mar 15, 2016

screen shot 2016-03-15 at 10 47 29

Such a dick ACF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment