I am trying to add a page to WordPress programatically. I am using this code:
function add_media_page(){
if(!(is_page('My New Post'))){
// Create post object
$my_post = array(
'post_title' => 'My new Post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => ['page']
);
// Insert the post into the database
wp_insert_post( $my_post );
}
}
add_action( 'init', 'add_media_page' );
However when i use the last line in the array 'post_type' => ['page'] it causes the admin to crash and show a blank page. Does anyone know what's happening here
$my_postarray - so it should be just'page'. – OleVik Jan 13 '12 at 21:19