Skip to content

Instantly share code, notes, and snippets.

@ajskelton
Created December 29, 2018 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajskelton/fef2b7910f6ade49f31bd9a7286ac63c to your computer and use it in GitHub Desktop.
Save ajskelton/fef2b7910f6ade49f31bd9a7286ac63c to your computer and use it in GitHub Desktop.
add_filter( 'acf/load_value/name=content_blocks', 'default_fields', 10, 3 );
function default_fields( $value, $post_id, $field ) {
// Only add default content for new posts
if ( $value !== null ) {
return $value;
}
// Only add default content for certain post types
if ( ! in_array(
get_post_type( $post_id ),
array(
@TODO Post Types
) ) ) {
return $value;
}
// Set up your initial post, then get the field id's of the settings you want to set
// They look like: field_5b4e57efd0660_field_5b4e63e479d81
// Add them after the acf_fc_layout
$value = array(
array(
'acf_fc_layout' => 'name_of_layout',
),
array(
'acf_fc_layout' => 'another_layout',
)
);
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment