Skip to content

Instantly share code, notes, and snippets.

@gagimilicevic
Forked from yratof/load.php
Created April 11, 2020 20:16
Show Gist options
  • Save gagimilicevic/aa28b4505a58fbdb37ca3f87fb5fb83d to your computer and use it in GitHub Desktop.
Save gagimilicevic/aa28b4505a58fbdb37ca3f87fb5fb83d to your computer and use it in GitHub Desktop.
ACF Load layouts into flex field
<?php
add_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' );
static function craft_content_layouts( $field ) {
// Remove the layouts
// that are named in this list
$remove_list = [
'paragraph',
'banner',
];
foreach ( $field['layouts'] as $i => $layout ) {
if ( in_array( $layout['name'], $remove_list ) ) {
unset( $field['layouts'][ $i ] );
}
}
/**
* Load another AC Flex field into this layout mix
*/
// $additional_fields = acf_get_fields( 'additional_flex_field' );
// foreach ($additional_fields['layouts'] as $layout) {
// $field['layouts'][] = $layout;
// }
return $field;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment