• I have the following code in my theme functions file. The idea is to insert a page with content into the database just once when the theme is first activated. The problem is that it adds the page over an dover again every time the page is refreshed.

    Could someone identify what I could add to make this obly happen once when the theme is activated.

    <?php
    $my_post = array();
    $my_post [‘post_title’] = ‘Page 1’;
    $my_post [‘post_content’] = ‘[Short Code 1]’;
    $my_post [‘post_status’] = ‘publish’;
    $my_post [‘post_author’] = 1;
    $my_post [‘post_type’] = ‘page’;

    wp_insert_post( $my_post );
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to do wp_insert_post only once’ is closed to new replies.