Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wordpress add new page programmatically

$new_page = array(
    'comment_status' => 'close',
    'ping_status' => 'close',
    'post_author' => $user_ID,
    'post_title' => ucwords('title_of_the_page'),
    'post_name' => strtolower(str_replace(' ', '-', trim('title_of_the_page'))),
    'post_status' => 'publish',
    'post_content' => 'Content of the page',
    'post_type' => 'page',
    'post_parent' => 'id_of_the_parent_page_if_it_available'
);
$post_id = wp_insert_post($new_page);
 
PREVIOUS NEXT
Tagged: #wordpress #add #page #programmatically
ADD COMMENT
Topic
Name
8+8 =