我试图在wordpress管理导航栏中添加一个菜单链接。我期待一个像这样的链接
/wp-admin/admin.php?page=function_name
我使用的代码是
add_submenu_page( \'nxssnap\',__( \'Calendar View\', \'social-networks-auto-poster-facebook-twitter-g\' ), __( \'Calendar View\', \'social-networks-auto-poster-facebook-twitter-g\' ), \'manage_options\', \'nxs-function_name\', array( $this, \'showPage_about\' ) ,0 );
我从上述代码中得到的链接是
/wp-admin/function_name
我需要做什么更改才能附加此
admin.php?page= 在URL的开头
这是我正在尝试添加子菜单的主菜单项。
$this->page = add_menu_page( \'Social Networks Auto Poster\', \'SNAP|AutoPoster\',\'haveown_snap_accss\',\'nxssnap\',array( $this, \'showPage_accounts\' ), NXS_PLURL.\'img/snap-icon.png\');
SO网友:Max Yudin
看起来您添加页面的方式不对。
下面是它在类中的外观:
class My_Add_Menu_Pages {
public function __construct() {
add_action( \'admin_menu\', array( $this, \'my_custom_admin_pages\' ) );
}
public function my_custom_admin_pages() {
add_menu_page(
\'Social Networks Auto Poster\',
\'SNAP|AutoPoster\',
\'haveown_snap_accss\',
\'nxssnap\',
array(
$this,
\'showPage_accounts\'
)
);
add_submenu_page(
\'nxssnap\',
__( \'Calendar View\', \'social-networks-auto-poster-facebook-twitter-g\' ),
__( \'Calendar View\', \'social-networks-auto-poster-facebook-twitter-g\' ),
\'manage_options\',
\'nxs-function_name\',
array(
$this,
\'showPage_about\'
)
);
}
public function showPage_accounts() {
echo \'<h1>Parent Page</h1>\';
}
public function showPage_about() {
echo \'<h1>Child Page</h1>\';
}
}
new My_Add_Menu_Pages;