Title: Theme Function run once on setup
Last modified: August 19, 2016

---

# Theme Function run once on setup

 *  [14850842](https://wordpress.org/support/users/14850842-1/)
 * (@14850842-1)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/theme-function-run-once-on-setup/)
 * I am using a program to replicate my blog theme on a number of domains. I have
   setup the theme and it is ready to be installed. I however am looking to add 
   a function to the setup of the theme. I am looking to run a function that adds
   two pages to the wordpress database using wp_insert_post. I have the code to 
   insert the posts but I do not know how to add a function to the admin setup that
   will be run only once when the blog is installed and setup. I have tried a few
   function but either it does nothing at all or it creates 6 instances of the page.
 * Can anyone help me with this.
 * The theme is the inspire woo theme framework.
 * Thanks

Viewing 1 replies (of 1 total)

 *  [stri8ed](https://wordpress.org/support/users/stri8ed/)
 * (@stri8ed)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/theme-function-run-once-on-setup/#post-2033100)
 * Here is an idea that could work,
 * Add the function, and at the end of the function set a new wordpress option (
   [http://codex.wordpress.org/Function_Reference/update_option](http://codex.wordpress.org/Function_Reference/update_option))
   
   called “this_has_run” with a value of “yes”.
 * Now revise your function,
 *     ```
       //First check it make sure this function has not been done
       if (get_option('this_has_run') != "yes") {
   
       // your function here
   
       //now that function has been run, set option so it wont run again
       update_option( 'this_has_run', 'yes' );
   
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Theme Function run once on setup’ is closed to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [Setup](https://wordpress.org/support/topic-tag/setup/)
 * [Themes](https://wordpress.org/support/topic-tag/themes/)

 * 1 reply
 * 2 participants
 * Last reply from: [stri8ed](https://wordpress.org/support/users/stri8ed/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/theme-function-run-once-on-setup/#post-2033100)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
