答案 0 :(得分:0)
这真的很简单,只是需要一点点习惯。
理想情况下,您需要遵循以下文档:
https://codex.wordpress.org/Adding_Administration_Menus https://developer.wordpress.org/reference/functions/add_menu_page/
这将指导您如何设置管理菜单。
<?php add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); ?>
将是创建管理侧边栏菜单项时调用的代码,但是,还有更多用于在其下创建子菜单页面的功能。
我认为您正在寻找的是针对客户的自定义帖子类型...
https://codex.wordpress.org/Post_Types
function create_post_type() {
register_post_type( 'client_posttype',
array(
'labels' => array(
'name' => __( 'Clients' ),
'singular_name' => __( 'Client' )
),
'public' => true,
'has_archive' => true,
)
);
}
add_action( 'init', 'create_post_type' );
与上述类似的操作将使您入门。
如果太多,您可以生成CPT代码:
https://generatewp.com/post-type/
然后查看生成的代码,弄清楚您自己编写的代码是什么。
答案 1 :(得分:0)
测试此:)
class options_page {
function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
}
function admin_menu() {
add_menu_page( 'Clients', 'Clients Page', 'edit_posts', 'clients_page', 'my_clients', '', 24);
}
function settings_page() {
echo 'This is the page content';
}
}
new options_page;