-
-
Save gagimilicevic/aa28b4505a58fbdb37ca3f87fb5fb83d to your computer and use it in GitHub Desktop.
ACF Load layouts into flex field
This file contains 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
<?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