Created
December 29, 2018 01:12
-
-
Save ajskelton/fef2b7910f6ade49f31bd9a7286ac63c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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