如何创建插件自动创建页面WordPress?

时间:2015-05-26 作者:Nguyen Quoc Thang

我想一个插件可以创建自动网页插入到数据库wordpress。怎样

1 个回复
SO网友:Domain

从仪表板激活插件时,将调用以下挂钩。

register_activation_hook( __FILE__, \'myplugin_activate\' );
function myplugin_activate() {
   //create a variable to specify the details of page
   $post = array(     
             \'post_content\'   => \'content\', //content of page
             \'post_title\'     =>\'title\', //title of page
             \'post_status\'    =>  \'publish\' , //status of page - publish or draft
             \'post_type\'      =>  \'page\'  // type of post
   );
   wp_insert_post( $post ); // creates page
}

结束

相关推荐

merge wordpress plugins

codecanyon-577696-security-ninja codecanyon-2927931-core-scanner-addon-for-security-ninja codecanyon-3686330-scheduled-scanner-addon-for-security-ninja codecanyon-8531381-events-logger-addon-for-security-ninja 所有四个都在zip文件中,所以我想创建一个zip,所以每