{"id":94383,"date":"2012-08-20T12:00:57","date_gmt":"2012-08-20T16:00:57","guid":{"rendered":"http:\/\/wpmu.org\/?p=94383"},"modified":"2012-08-19T14:56:48","modified_gmt":"2012-08-19T18:56:48","slug":"add-links-wordpress-admin-bar-toolbar","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/add-links-wordpress-admin-bar-toolbar\/","title":{"rendered":"How to Add Links to the WordPress Admin Bar \/ Toolbar"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-94387\" title=\"add-links\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/08\/add-links.jpg\" alt=\"Post image\" aria-hidden=\"true\" width=\"699\" height=\"479\" \/><br \/>\nIf you\u2019d like to add links to your Admin Toolbar (formerly called the Admin Bar), then there are two ways you can go about that: You can use a plugin, or you can use code in your functions file. We\u2019ll go over both ways below.<\/p>\n<h2><strong>1. Plugin \u2013 <a href=\"https:\/\/wpmudev.com\/project\/custom-admin-bar\/\" target=\"_blank\">Custom Admin Bar<\/a><\/strong><\/h2>\n<p>Of course we need look no further than <a href=\"https:\/\/wpmudev.com\/project\/custom-admin-bar\/\" target=\"_blank\">WPMU DEV\u2019s own Custom Admin Bar plugin<\/a> to do the trick of adding links to our Admin Toolbar.<\/p>\n<p>This is a FREE plugin, but like all plugins from WPMU DEV, it sees regular updates to insure compatibility with the latest versions of WordPress.<\/p>\n<p>The Custom Admin Bar plugin lets you \u2026<\/p>\n<ul>\n<li>Create dropdown menus<\/li>\n<li>Use and image for a top menu item<\/li>\n<li>Easily link to internal or external pages<\/li>\n<li>Drag and drop menu items to sort them<\/li>\n<li>Create a menu \u201chub\u201d item that doesn\u2019t link anyway but has sub-menu items that do<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Here\u2019s a look at adding a link.<\/strong><\/p>\n<p>First choose the type of link it is:<\/p>\n<ul>\n<li>Link to an internal admin page<\/li>\n<li>Link to internal Post or Page<\/li>\n<li>Link to external site<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-94390\" title=\"typp-of-admin-bar-link\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/08\/typp-of-admin-bar-link.jpg\" alt=\"Post image\" aria-hidden=\"true\" width=\"705\" height=\"203\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Then add the name for the menu item and link for the page.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-94391\" title=\"settings-add-links-admin-toolbar\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/08\/settings-add-links-admin-toolbar.jpg\" alt=\"Post image\" aria-hidden=\"true\" width=\"705\" height=\"375\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>And here&#8217;s a look at the result.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-94398\" title=\"custom-links-admin-toolbar\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/08\/custom-links-admin-toolbar.jpg\" alt=\"Post image\" aria-hidden=\"true\" width=\"706\" height=\"508\" \/><\/p>\n<p>Here\u2019s a short video of the process to show you how quick and easy it is.<\/p>\n<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><span class=\"embed-youtube-lazy-id dev-hidden\">xKrOCd9bnSY<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n\n<p>&nbsp;<\/p>\n<h2><strong>2. Code in Functions File<\/strong><\/h2>\n<p>If you\u2019d like, you can also add new links to your Admin Toolbar by inserting code into your functions.php file. (Appearance &gt; Editor &gt; Theme Functions \u2013 functions.php) This doesn\u2019t offer all the options the Custom Admin Bar plugin does, but it will add your links for you.<\/p>\n<p>You will just need to fill in the code with your own information in various places where required.<\/p>\n<pre>add_action('admin_bar_menu', 'add_toolbar_items', 100);\r\nfunction add_toolbar_items($admin_bar){\r\n\u00a0\u00a0 \u00a0$admin_bar-&gt;add_menu( array(\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'id'\u00a0\u00a0\u00a0 =&gt; 'my-item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'title' =&gt; 'My Item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'href'\u00a0 =&gt; '#',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'meta'\u00a0 =&gt; array(\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'title' =&gt; __('My Item'),\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0),\r\n\u00a0\u00a0 \u00a0));\r\n\u00a0\u00a0 \u00a0$admin_bar-&gt;add_menu( array(\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'id'\u00a0\u00a0\u00a0 =&gt; 'my-sub-item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'parent' =&gt; 'my-item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'title' =&gt; 'My Sub Menu Item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'href'\u00a0 =&gt; '#',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'meta'\u00a0 =&gt; array(\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'title' =&gt; __('My Sub Menu Item'),\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'target' =&gt; '_blank',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'class' =&gt; 'my_menu_item_class'\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0),\r\n\u00a0\u00a0 \u00a0));\r\n\u00a0\u00a0 \u00a0$admin_bar-&gt;add_menu( array(\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'id'\u00a0\u00a0\u00a0 =&gt; 'my-second-sub-item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'parent' =&gt; 'my-item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'title' =&gt; 'My Second Sub Menu Item',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'href'\u00a0 =&gt; '#',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'meta'\u00a0 =&gt; array(\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'title' =&gt; __('My Second Sub Menu Item'),\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'target' =&gt; '_blank',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'class' =&gt; 'my_menu_item_class'\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0),\r\n\u00a0\u00a0 \u00a0));\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>Thanks to <a href=\"http:\/\/wp-snippets.com\/add-links-to-wordpress-3-3-new-toolbar\/\" target=\"_blank\">wp-snippets<\/a> for this code.<\/p>\n\n<p>Photo: <a href=\"http:\/\/www.bigstockphoto.com\/image-2126897\/stock-photo-chain-link-close-up\" target=\"_blank\">Chain Link Close Up<\/a> from BigStock<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Get customized links in prominent positions on your Admin Toolbar <\/p>\n","protected":false},"author":84404,"featured_media":94388,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[4],"tags":[8822],"tutorials_categories":[],"class_list":["post-94383","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-plugins","tag-toolbar"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/94383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/84404"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=94383"}],"version-history":[{"count":1,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/94383\/revisions"}],"predecessor-version":[{"id":216510,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/94383\/revisions\/216510"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/94388"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=94383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=94383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=94383"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=94383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}