php - How can I add a Submenu to the WordPress Admin Bar -
i need add dropdown menu wordpress in admin bar include multiple links. best solution?
i looking answer question while , couldn't find solution on here thought help! found great blog post , perfect solution question:
http://davidwalsh.name/add-submenu-wordpress-admin-bar
like adding functionality theme , other admin area, directives go in theme's functions.php file. code should self explanatory:
function create_dwb_menu() { global $wp_admin_bar; $menu_id = 'dwb'; $wp_admin_bar->add_menu(array('id' => $menu_id, 'title' => __('dwb'), 'href' => '/')); $wp_admin_bar->add_menu(array('parent' => $menu_id, 'title' => __('homepage'), 'id' => 'dwb-home', 'href' => '/', 'meta' => array('target' => '_blank'))); $wp_admin_bar->add_menu(array('parent' => $menu_id, 'title' => __('drafts'), 'id' => 'dwb-drafts', 'href' => 'edit.php?post_status=draft&post_type=post')); $wp_admin_bar->add_menu(array('parent' => $menu_id, 'title' => __('pending comments'), 'id' => 'dwb-pending', 'href' => 'edit-comments.php?comment_status=moderated')); } add_action('admin_bar_menu', 'create_dwb_menu', 2000); setting id on parent menu item allows use parent key submenu items; rest of keys easy figure out. menu created, need add wordpress hook , specificity add it!
Comments
Post a Comment