Advertisement
meetsos

Add external links in WP Admin Menus & Submenus

Jan 11th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. add_action('admin_menu', 'admin_menu_add_external_links_as_submenu');
  2.  
  3. function admin_menu_add_external_links_as_submenu() {
  4.     global $submenu;
  5.  
  6.     $menu_slug = "externallink"; // used as "key" in menus
  7.     $menu_pos = 1; // whatever position you want your menu to appear
  8.  
  9.     // create the top level menu
  10.     add_menu_page( 'external_link', 'External Links', 'read', $menu_slug, '', 'dashicons-welcome-learn-more
  11. ', $menu_pos);
  12.  
  13.     // add the external links to the slug you used when adding the top level menu
  14.     $submenu[$menu_slug][] = array('Example', 'manage_options', 'http://www.example.com/');
  15.     $submenu[$menu_slug][] = array('Google', 'manage_options', 'https://www.google.com/');
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement