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
- start_lvl Ignored in Custom walker_nav_menu
- Menu Items Disappearing
- Customize default settings on new sites on multisite
- wp_delete_auto_drafts() deletes links in menus
- Sorting list of sites from multisite network using wp_get_sites
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- Check if a menu is empty?
- Walker class: Problems with understanding how walk() method can be called without error
- How to Use the Function is_user_logged_in To Display Different Menus?
- Replacing a specific menu item
- How to show only parents subpages of current page item in vertical menu?
- How can I access the “description” of a menu item?
- How can I add a class to a single menu item?
- Admin Menus – Name Menu different from first Submenu [duplicate]
- Remove all nav menu classes ( but keep useful ones… )
- How can I add a custom class to only nav sub-menu > li > a items in WordPress?
- items_wrap not working
- Style wp_page_menu() items
- Create Logout Link WordPress Admin Menu
- Have CSS Class Added with `is_page()` WP function
- Run a filter when a walker runs
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- Input type search in Menu
- WP Walker using custom css classes
- Change list item content in menu navigation to add a child element with specific class
- Automatically adding new post categories to menu
- WordPress returns “The link you followed has expired” error page whenever I add a new site, add a user etc
- Child page menu in sidebar
- Title Case WordPress Menu Items
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Pagination in plugin’s backend
- Trying to store submenu items to render out after main menu
- How to change menu order item
- get_the_title() gets printed out twice
- Moving code from theme header to functions.php
- Two menus show up
- Change order of custom submenu link in WP Admin?
- Register a menu – Error Header
- Count posts on multisite with blog id
- Show About and Contact Us page when they’re clicked in the top menu.
- Parsing Menu Items and Blog Posts
- How do I display offsite database info on my wordpress site?
- Some menu items wont budge
- 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
- WordPress homepage setup not working on first load
- Get css class of menu item in custom menu structure
- Extend Menu Walker Output
- 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?
- Show login greeting above sub-menu links?
- Why can’t I add a custom image in my navigation?
- conditional: if is page, and all subpages
- need help adding a new sidebar to a page that can’t use page-templates -> multisite
- Menu not styling. New menus functionality giving me a headache
- Dynamic menu with custom post types
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Adding markup to sub menu based on class
- How to make only the valid active page of a multilevel menu active with – “.nav li.current-menu-item a”?
- How to put 2 php codes in functions.php without site crashing
- Internal Server Errors – Moving working multi-site install to my localhost
- Menu not updating for logged in users after redirect
- wp_get_nav_menu_items() with ACF
- How to switch between two primary menus (programatically0
- Used a code to revoke some dashboard menus for my contributors but for some reason it’s revoked me access to the editor [closed]
- Annoying/confusing WordPress memory limit exhausted
- How to give custom roles the capability to edit one Menu instead of every Menu
- Primary navigation menu with timed items from custom post type
- Redirect user role to a specific page on login in a multisite network?
- Add parent menu item in sub-menu in custom nav_walker
- Changable favicon
- Add Admin Option w/ Anonymous Function
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- add menu page in loop menu order
- Adding users to another blog
- How limit the width of a fixed menu-bar on scroll?
- Beyond widget side menu editing, with the php page, custom template
- Issue with search form admin panel after PHP migration
- Importing demo data in Multisite
- Two theme locations for two menus, but only one is showing up
- Contact form field in wordpress menu
- Active class not working on custom menu link using add_menu_page
- Sidebar current menu item for parent
- Remove all nav menu classes except those which begin with certain letters
- How to add a code for lastpostdate after/inside a specific menu link?
- Add the “.current-menu-item” class to tag?
- WordPress adding in site URL to header links
- How to change the menu color
- Can’t remove menu items added by plugin
- Nav Menu Display
- Adding a unique class to wp_nav_menu
- .htaccess on multisite and roots theme?
- Open WordPress Page from selected option dropdown
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico