search ]

Pre-populating Post Types with Default Content

The following snippet lets you add default content automatically to every new post of a given post type. Add to functions.php:

<?php
////////////////////////////////////////////////////////////////////////////////////
// This auto populates post types and posts.
///////////////////////////////////////////////////////////////////////////////////


function my_editor_content( $content ) {

	global $post_type;

	switch( $post_type ) {
		case 'your_post_type_here': //auto populate
			$content = 'The content you want to pre-populate the post type with.';
			break;
	}

	return $content;
}
add_filter( 'default_content', 'my_editor_content' );

For more on custom post types, see How to Create Custom Post Types.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo