• 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)
  • Here is an idea that could work,

    Add the function, and at the end of the function set a new wordpress option (https://codex.www.ads-software.com/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.