Support » Fixing WordPress » wp insert post – but only once?

  • Hi,

    I’m developing a theme and my client wants that with theme activation the theme would set up several pages automatically. I was referred to this function:
    wp_insert_post

    And so far I got into function.php the following:

    // Create post object
      $my_post = array();
      $my_post['post_title'] = 'My post';
      $my_post['post_content'] = 'This is my post.';
      $my_post['post_status'] = 'publish';
      $my_post['post_type'] = 'page';
    
    // Insert the post into the database
      wp_insert_post( $my_post );

    The post is inserted into database successfully, but it does so every time the function.php is called. How to make it active only once, on theme activation only?

    I’d appreciate any tips.

    Andrew

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp insert post – but only once?’ is closed to new replies.