Created
August 24, 2022 17:39
-
-
Save jessedmatlock/8f9048a812aeb7da8b15ce5cf07bd67f to your computer and use it in GitHub Desktop.
Load specific ACF Flexible Content fields for new Posts
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
// "flexible_content" below, is the name of the Flexible Content field | |
add_filter('acf/load_value/name=flexible_content', 'add_fields', 10, 3); | |
function add_fields($value, $post_id, $field) { | |
if ($value !== NULL) { // $value will only be empty for New Posts | |
return $value; | |
} | |
// lead layouts | |
$value = array( | |
array( | |
'acf_fc_layout' => 'heading' // heading is the name of the layout | |
), | |
array( | |
'acf_fc_layout' => 'wysiwyg_editor' // wysiwyg_editor is the name of the layout | |
) | |
); | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment