我正在尝试创建一个简单的插件,只创建一个新帖子。我写的代码每秒都会创建一篇相同的新帖子。下面是我的代码。需要添加什么才能只创建一个帖子?
<?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\' );
?>