{"id":12196,"date":"2022-05-11T04:48:34","date_gmt":"2022-05-11T08:48:34","guid":{"rendered":"http:\/\/local.brightwhiz\/?post_type=snippets&p=12196"},"modified":"2022-05-11T04:48:36","modified_gmt":"2022-05-11T08:48:36","slug":"wordpress-create-new-page-programmatically","status":"publish","type":"snippets","link":"http:\/\/local.brightwhiz\/snippets\/wordpress-create-new-page-programmatically\/","title":{"rendered":"Create new Page Programmatically in WordPress"},"content":{"rendered":"\n
Use this code snippet to programmatically create new page in WordPress:<\/p>\n\n\n\n
$new_page = array(\n 'post_title' => ucwords( 'title_of_the_page' ),\n 'post_name' => strtolower(str_replace( ' ', '-', trim('title_of_the_page') ) ),\n 'post_status' => 'publish',\n 'post_content' => 'Content of the page',\n 'post_author' => $user_ID,\n 'post_type' => 'page',\n 'comment_status' => 'close',\n 'ping_status' => 'close',\n 'post_parent' => 'id_of_parent_page_if_available'\n);\n$post_id = wp_insert_post( $new_page );<\/code><\/pre>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[953,15],"tags":[136,350,433,449,452,471,544,651],"yoast_head":"\nWordPress Create new Page Programmatically Example<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n