0
我使用類似的東西來添加頁面,當我的Wordpress插件被激活。防止插件激活時出現重複頁面(或取消發佈插件停用時的頁面)
function create_wordpress_pages(){
$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_author'] = 1;
$my_post['post_type'] = 'page';
wp_insert_post($my_post);
}
register_activation_hook(__FILE__, 'create_wordpress_pages');
這很好(而且很花哨),但是我不想在每次停用這個插件時重新創建這個頁面。如何檢查該頁面是否存在或取消發佈插件停用?