Skip to content

Instantly share code, notes, and snippets.

@jessedmatlock
Created August 24, 2022 17:39
Show Gist options
  • Save jessedmatlock/8f9048a812aeb7da8b15ce5cf07bd67f to your computer and use it in GitHub Desktop.
Save jessedmatlock/8f9048a812aeb7da8b15ce5cf07bd67f to your computer and use it in GitHub Desktop.
Load specific ACF Flexible Content fields for new Posts
// "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