Default Content for New Posts
Pre-fills new posts or pages with starter content, such as a block layout or a checklist, so writers start from your template.
Opens WPIDE on
Code
// Post type => starter content (block markup works in the block editor).
$wpide_default_content = array(
'post' => "<!-- wp:paragraph -->\n<p>Intro: what will the reader learn?</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:heading -->\n<h2 class=\"wp-block-heading\">Main point</h2>\n<!-- /wp:heading -->\n\n<!-- wp:paragraph -->\n<p></p>\n<!-- /wp:paragraph -->",
);
add_filter( 'default_content', function ( $content, $post ) use ( $wpide_default_content ) {
$type = $post ? get_post_type( $post ) : '';
return ( '' === $content && isset( $wpide_default_content[ $type ] ) ) ? $wpide_default_content[ $type ] : $content;
}, 10, 2 );
Notes
Only new items are pre-filled; existing content is never changed.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.