Skip to content

Instantly share code, notes, and snippets.

@bradpotter
Last active December 15, 2017 23:06
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 bradpotter/a2cb88757c7e95080ce2d9ef4029fb7c to your computer and use it in GitHub Desktop.
Save bradpotter/a2cb88757c7e95080ce2d9ef4029fb7c to your computer and use it in GitHub Desktop.
Modify post type for Gutenberg
function modify_post_type() {
//new args
$args = array(
'public' => true,
'label' => 'Posts',
'show_in_rest' => true,
'template' => array(
array( 'core/cover-image' ),
array( 'core/image' ),
array( 'core/quote' ),
array( 'core/heading' ),
array( 'core/embed' ),
array( 'core/paragraph' ),
array( 'core/paragraph' ),
array( 'core/paragraph' ),
),
);
//re-register the post type to include new args
register_post_type( 'post', $args );
}
add_action( 'init', 'modify_post_type' );
@youknowriad
Copy link

You can also do:

$post_type = get_post_type_object( 'post' );
$post_type->template = array(
  array( 'core/cover-image' ),
  array( 'core/image' ),
  array( 'core/quote' ),
  array( 'core/paragraph' ),
);

@bradpotter
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment