{"id":54139,"date":"2017-02-09T17:41:59","date_gmt":"2017-02-09T19:41:59","guid":{"rendered":"https:\/\/wiki.samuelchopard.ch\/?p=54139"},"modified":"2020-05-03T18:44:33","modified_gmt":"2020-05-03T16:44:33","slug":"how-to-add-links-to-the-wordpress-admin-bar-toolbar","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/how-to-add-links-to-the-wordpress-admin-bar-toolbar\/","title":{"rendered":"How to add links to the WordPress admin bar\/toolbar"},"content":{"rendered":"<p><!--more--><\/p>\n<p>In your <a target=\"_blank\" href=\"https:\/\/samuelchopard.ch\/wiki\/2016\/05\/29\/download-blank-child-theme\/\" target=\"_blank\" rel=\"noopener noreferrer\">child-theme<\/a>&#8216;s functions.php, add the following code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">\r\nadd_action('admin_bar_menu', 'add_toolbar_items', 100);\r\nfunction add_toolbar_items($admin_bar){\r\n    $admin_bar->add_menu( array(\r\n        'id'    => 'my-item',\r\n        'title' => 'My Item',\r\n        'href'  => '#',\r\n        'meta'  => array(\r\n            'title' => __('My Item'),            \r\n        ),\r\n    ));\r\n    $admin_bar->add_menu( array(\r\n        'id'    => 'my-sub-item',\r\n        'parent' => 'my-item',\r\n        'title' => 'My Sub Menu Item',\r\n        'href'  => '#',\r\n        'meta'  => array(\r\n            'title' => __('My Sub Menu Item'),\r\n            'target' => '_blank',\r\n            'class' => 'my_menu_item_class'\r\n        ),\r\n    ));\r\n    $admin_bar->add_menu( array(\r\n        'id'    => 'my-second-sub-item',\r\n        'parent' => 'my-item',\r\n        'title' => 'My Second Sub Menu Item',\r\n        'href'  => '#',\r\n        'meta'  => array(\r\n            'title' => __('My Second Sub Menu Item'),\r\n            'target' => '_blank',\r\n            'class' => 'my_menu_item_class'\r\n        ),\r\n    ));\r\n}<\/pre>\n<p>Change the information as needed.<\/p>\n<p>Source: <a target=\"_blank\" href=\"https:\/\/premium.wpmudev.org\/blog\/add-links-wordpress-admin-bar-toolbar\/?mkpp=b&amp;utm_expid=3606929-97.J2zL7V7mQbSNQDPrXwvBgQ.1&amp;utm_referrer=https%3A%2F%2Fwww.google.com.br%2F\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/premium.wpmudev.org\/blog\/add-links-wordpress-admin-bar-toolbar\/?mkpp=b&amp;utm_expid=3606929-97.J2zL7V7mQbSNQDPrXwvBgQ.1&amp;utm_referrer=https%3A%2F%2Fwww.google.com.br%2F<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"In your child-theme's functions.php, add the following code: add_action('admin_bar_menu', 'add_toolbar_items', 100); function add_toolbar_items($admin_bar){ $admin_bar->add_menu( array( 'id' => 'my-item', 'title' => [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,3,9],"tags":[19,24,40,73,76,161,299],"class_list":["post-54139","post","type-post","status-publish","format-standard","hentry","category-dashboard","category-php-tricks","category-wordpress","tag-add","tag-admin","tag-bar","tag-custom","tag-dashboard","tag-links","tag-toolbar"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=54139"}],"version-history":[{"count":3,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54139\/revisions"}],"predecessor-version":[{"id":55114,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54139\/revisions\/55114"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}