how to add new pages using WP core function

how can I add a page using core functions of wordpress.I can find function for Post etc as well but couldn’t find any for Pages.Any one who can help me
Thanks

Related posts

Leave a Reply

1 comment

  1. You use the same function to add posts or pages, just add the post_type parameter like this :

    $args = array( 'post_type'  => 'page',
                   'post_content' => 'You content...',
                   'post_parent' => $parent_id; // ID of the page this one should be a child of
    ... // etc.
    ...
                   'post_title' => 'Title for your page');
    
    wp_insert_post ($args);