Title: wp_insert_post() inserts 2 posts
Last modified: August 20, 2016

---

# wp_insert_post() inserts 2 posts

 *  [miniCarl](https://wordpress.org/support/users/minicarl/)
 * (@minicarl)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_post-inserts-2-posts/)
 * When i run the function wp_insert_post(), it inserts two identical posts instead
   of one.
    By placing echo’s, I have confirmed that the function is not called 
   twice.
 * Here is some of my code:
 *     ```
       // Insert Pages
       $about = array(
       	'post_type' => 'page',
       	'post_status' => 'publish',
       	'post_title' => 'Om webbplatsen',
       	'post_content' => 'Content
       More content
       And even mode content'
       );
   
       wp_insert_post($about);
       ```
   
 * You can download my full theme here;
    [http://www.fristil.se/skal.rar](http://www.fristil.se/skal.rar)
   The wp_insert_posts() is called in functions.php at row 44.
 * Thankful for any help!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [miniCarl](https://wordpress.org/support/users/minicarl/)
 * (@minicarl)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_post-inserts-2-posts/#post-2182190)
 * Bump
 *  Moderator [Dion Hulse](https://wordpress.org/support/users/dd32/)
 * (@dd32)
 * Meta Developer
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_post-inserts-2-posts/#post-2182191)
 * Chances are, it’s a Ajax request or cron request which is happening at the same
   time.
 * I’d do something like this instead:
 *     ```
       $opt = get_option(..)
       if ( is_admin() && !$option ) {
       update_option(..);
       //Do my long processes here
       }
       ```
   
 * Also… Please don’t release a theme like that that sets the permalink structure
   to something upon activation, Respect your users choices
 *  Thread Starter [miniCarl](https://wordpress.org/support/users/minicarl/)
 * (@minicarl)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_post-inserts-2-posts/#post-2182196)
 * This doesn’t make a difference as im testing the code without conditions…
 *     ```
       $check = get_option('fristil_theme_activation_check');
       		if(TRUE || $check != "set" ){
       ```
   
 * …or i totally missunderstood you

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wp_insert_post() inserts 2 posts’ is closed to new replies.

## Tags

 * [advanced](https://wordpress.org/support/topic-tag/advanced/)
 * [wp_insert_post](https://wordpress.org/support/topic-tag/wp_insert_post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [miniCarl](https://wordpress.org/support/users/minicarl/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/wp_insert_post-inserts-2-posts/#post-2182196)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
