对于外部链接,这将使用add_menu_page
或add_submenu_page
. 只要换一下http://www.google.com
下面是您所需的链接:
function add_custom_menu_item_external_url(){
add_menu_page( \'My Posts\', \'My Posts\', \'manage_options\', \'link-to-google\', \'custom_menu_item_redirect\', \'dashicons-admin-links\', 1 );
}
add_action( \'admin_menu\', \'add_custom_menu_item_external_url\' );
function custom_menu_item_redirect_external_link() {
$menu_redirect = isset($_GET[\'page\']) ? $_GET[\'page\'] : false;
if($menu_redirect == \'link-to-google\' ) {
header(\'Location: http://www.google.com\');
exit();
}
}
add_action( \'admin_init\', \'custom_menu_item_redirect_external_link\', 1 );
对于内部链接,请在下面使用并更改home\\u url()或类似登录的内容
author page 检查一下:
function add_custom_admin_menu_page_home_url(){
add_menu_page( \'Home\', \'Home\', \'manage_options\', \'home-redirect\', \'custom_menu_item_redirect_home_url\', \'dashicons-admin-links\', 1 );
}
add_action( \'admin_menu\', \'add_custom_admin_menu_page_home_url\' );
function custom_menu_item_redirect_home_url() {
$menu_redirect = isset($_GET[\'page\']) ? $_GET[\'page\'] : false;
if($menu_redirect == \'home-redirect\' ) {
wp_safe_redirect( home_url() );
exit();
}
}
add_action( \'admin_init\', \'custom_menu_item_redirect_home_url\', 1 );