WordPress.org

Ready to get started?Download WordPress

Forums

Automatic Page Creation (3 posts)

  1. nickkos
    Member
    Posted 1 year ago #

    I know of themes that automatically create pages when they are installed. And the same with plugins...I'd like to know how i can do this for the theme I am creating.

  2. Rebecca Schaefer
    Member
    Posted 1 year ago #

    You'll want to use wp_insert_post. That will let you generate any post/page you'd like, and will return the ID so you can update other options (like static front page, for example).

  3. parbat patel
    Member
    Posted 1 year ago #

    you can create in this way

    // Create post object
    $my_post = array(
    'post_title' => 'your post title',
    'post_content' => 'Your Post content or shortcode.',
    'post_status' => 'publish',
    'post_author' => 1,
    'post_category' => array(8,39)
    );

    // Insert the post into the database
    wp_insert_post( $my_post );

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.