I am trying to create a simple plugin that creates only one new post. The code I have written creates a the same new post every second. Below is the code I have. What would need to be added so it creates only one post?
<?php
/**
*@package blog-poster
*/
/*
Plugin Name: Blog Poster
Plugin URI: http://www.litliving.com
Description: This is a plugin for Litliving customers that allows for blog posts to be automatically posted.
Version: 1.0.0
Author: Ben Smith
Author URI: http://www.bengsmith.com
*/
if ( ! defined( 'ABSPATH') ){
die;
}
function AddThisPage() {
global $wpdb; // Not sure if you need this, maybe
$page = array(
'post_title' => 'My post!!!',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'post',
);
wp_insert_post($page);
}
add_action( 'wp_insert_post', 'AddThisPage' );
register_activation_hook( __FILE__, 'AddThisPage' );
?>