php - Wordpress - 激活插件后添加页面
解决方案
您应该使用插件的激活钩子,以便在插件激活时执行任何操作。
register_activation_hook( __FILE__, 'activation_hook_callback');
function activation_hook_callback()
{
//add the post type and other options in the array for the query
$page = array(
'post_status' => 'publish' ,
'post_title' => 'Page name',
'post_type' => 'page',
);
//add the page and ID will be saved.
$the_page_itself = wp_insert_post( $page );
}
这应该有效。
推荐阅读
- c++ - 永远不会收到发送到本地主机端口的数据包
- tableau-api - 为什么 Tableau 数据源必须始终为您选择查看的每个数据源保留“首次加载数据源”
- python - 在 html 个人资料页面中使用注册名字
- angular - Angular 失去了最重要的东西,绑定?
- ssis - SSIS - 源助手未显示项目级连接
- doctrine-odm - 从 Doctrine ODM/Document 访问原始 JSON
- r - 如何在 Excel 中迭代推动 ActiveX 命令按钮?
- python - 创建由两个区域组成的图像,均值相同但方差不同 Python
- json - Excel VBA 创建 json 有效负载
- jenkins - Jenkins 管道在 master 上占用“镜像”执行器