sau*_*rox -1 wordpress plugins
有人请帮忙!我有一个在后端创建post_type页面的插件。该插件正在创建所需的页面,但是问题是每当我尝试查看页面列表时,它都会显示“找不到页面”消息。萤幕撷取画面:http : //prnt.sc/azalub
我在此处创建所需页面的代码:
$new_page = array('post_title' => $title,
'post_content' => '['.$shortcode.']',
'post_status' => 'publish',
'post_type' => 'page'
);
$post_id = wp_insert_post( $new_page );
Run Code Online (Sandbox Code Playgroud)
为此,您需要向插件激活钩注册。
请参见下面的代码示例:
function add_my_custom_page() {
// Create post object
$my_post = array(
'post_title' => wp_strip_all_tags( 'My Custom Page' ),
'post_content' => 'My custom page content',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'page',
);
// Insert the post into the database
wp_insert_post( $my_post );
}
register_activation_hook(__FILE__, 'add_my_custom_page');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5014 次 |
| 最近记录: |