First thing get_current_theme()
is deprecated since version 3.4 you need to use wp get theme()
to get the current theme name.
And about add_menu() you can only use it at action hook admin_bar_menu
as codex say about it:
This is not a function. It is a method of the $wp_admin_bar global (an instance of WP_Admin_Bar), which may not exist except during the ‘admin_bar_menu’ hook.
Working example
function foo_test_menu() {
global $wp_admin_bar;
$current_theme = wp_get_theme();
$wp_admin_bar->add_menu( array(
'id' => 'your_menu_id',
'title' => $current_theme->get('Name')
) );
}
add_action('admin_bar_menu', 'foo_test_menu');
Related Posts:
- renaming an admin menu item with decimal array index number
- Remove submenu item from list
- How to call a certain object/menubar in a PHP file
- How to Customize the Admin Sidebar Menu in WordPress Multisite Network by changing the backend code of the wp-admin code files?
- Change list item content in menu navigation to add a child element with specific class
- How to change home or site url using action hooks or filter?
- Menu Limitations
- How can I Add a variable PHP in the Menu Nav
- Where to place PHP code that inserts (or doesn’t insert) menu item?
- Adding an Avatar to the Top Nav Bar
- Automatically adding new post categories to menu
- wordpress media library new uploads don’t write to database
- Add data attribute to each li in menu
- Remove metabox from WordPress menu editor page?
- WordPress returning 404 for multisite pages
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- How to call plugin function per site in a multisite?
- WordPress returns “The link you followed has expired” error page whenever I add a new site, add a user etc
- How to add an arrow to menu items has submenus
- wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu
- Unique icons next to each WordPress menu item
- Child page menu in sidebar
- Title Case WordPress Menu Items
- Secondary navigation menu on one page
- Remove class in nav_menu_link_attibutes filter
- NGINX rewrite rules for multisite
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Pagination in plugin’s backend
- Trying to store submenu items to render out after main menu
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- How to change menu order item
- WP & Server Speed [Teacher Question]
- Custom Menus: dynamic highlighting problem with custom home link
- get_the_title() gets printed out twice
- Redirect to another page using contact form 7? [closed]
- Add item to top of menu using a filter in functions.php
- Moving code from theme header to functions.php
- Adding PHP in the menu
- Two menus show up
- Is it best to avoid using $wpdb for security issues?
- Change order of custom submenu link in WP Admin?
- Register a menu – Error Header
- Count posts on multisite with blog id
- How to style one item from main navigation?
- Show About and Contact Us page when they’re clicked in the top menu.
- wp_redirect only works on main site and not on other sites
- New walker for walker_nav_menu to change inside container data
- Add data-id attribute to child page links
- Parsing Menu Items and Blog Posts
- How to avoid duplicates when creating recent network posts
- Add login hyperlink to secondary navigation menu
- How do I display offsite database info on my wordpress site?
- Timthumb.php image gallery not working on Multisite WordPress
- Automatically add images to a menu
- how to save checkbox data for custom setting?
- Find Site ID From WP_Post
- List all blogs, but exclude the main site
- Add value to new attribute inside WordPress menu items
- wp_nav_menu not working correctly in my underscores theme
- Admin submenu issue with PHP not detecting two strings as equal
- admin-ajax GET response bad request
- How to disable all logins except Network login in WordPress Multi site?
- Some menu items wont budge
- Menu Items fail to save correctly, cause reset of related page metadata
- Dropdown menu for categories
- Menu Custom Data Attributes
- How to display different submenus?
- Get the name of menu item with wp_nav_menu
- Known Issues in WordPress When Upgrading PHP to ver 7
- Notice: Trying to get property of non-object
- WordPress homepage setup not working on first load
- How to use wp_nav_menu to create custom dropdown menu?
- How to modify mobile nav menu text in theme
- Output only links using wp_nav_menu()
- Get css class of menu item in custom menu structure
- How to add aria role and schema markup to custom walker container
- How can I use custom menus with a Bootstrap WordPress theme?
- Nav menu from plugin to theme
- Adding Additional Variables on Menus Page
- Extend Menu Walker Output
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- Nav-Menu not showing up
- Why, when moving a WordPress multisite network, have my theme customisations stopped working?
- Custom navigation menu with awsAccordion
- how to add a div inside wp_page_menu
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Why in this WordPress theme I can’t see the Main Menu?
- Authentication from sub-folder non-wp cookie WordPress
- Show login greeting above sub-menu links?
- Why can’t I add a custom image in my navigation?
- Admin Menu new tab external link
- conditional: if is page, and all subpages
- wp nav menu: show submenu below li item
- How to tell if a user has gone in and created a menu
- need help adding a new sidebar to a page that can’t use page-templates -> multisite
- Dynamic Menu drops pages?
- How can I fix this code [duplicate]
- Class for Selected Menu using wp_nav_menu
- Remove the Tag from wp_nav_menu