For our customization want to create new page if it’s not exists then place the following snippet in functions.php within your theme folder!.

function create_new_page()
{
    global $user_ID;
    if( get_page_by_title('New Page')==NULL )
    {
	$new_post = array(
		      'post_title' => 'New Page',
		      'post_content' => 'New post content',
		      'post_status' => 'publish',
		      'post_date' => date('Y-m-d H:i:s'),
		      'post_author' => $user_ID,
		      'post_type' => 'page'
		);
	$post_id = wp_insert_post($new_post);
   }
}
add_action('init','create_new_page');

Have any doubt, then comment here!

Leave a Reply

Your email address will not be published. Required fields are marked *