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:
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.
- The topic ‘wp insert post – but only once?’ is closed to new replies.