WordPress.org

Support

Support » Plugins and Hacks » Hacks » Automatic Page Creation

Automatic Page Creation

  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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).

    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 );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Automatic Page Creation’ is closed to new replies.