You want to use $wp_admin_bar->add_node( $args ).
Below is a tested working example.
function wpse_add_toolbar_edit($wp_admin_bar) {
$wp_admin_bar->add_node( array(
'id' => 'mylink',
'title' => 'My New Link',
'href' => 'mailto:[email protected]',
'parent' => 'user-actions'
) );
}
add_action('admin_bar_menu', 'wpse_add_toolbar_edit', 999);
Note: The parent
param adds the link to an existing ID. If you need to find the correct ID to add your new link to you can var_dump($wp_admin_bar);
and look through the output for the correct ID.
Related Posts:
- How to fix the admin menu margin-top bug in WordPress 5.5?
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- Remove admin bar for subscribers
- renaming an admin menu item with decimal array index number
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- Admin Menus – Name Menu different from first Submenu [duplicate]
- Create Logout Link WordPress Admin Menu
- Why use the Settings API over a new administration menu?
- Pagination in plugin’s backend
- Change order of custom submenu link in WP Admin?
- how to save checkbox data for custom setting?
- Admin submenu issue with PHP not detecting two strings as equal
- admin-ajax GET response bad request
- Some menu items wont budge
- call adminbar greeting in other place
- Remove submenu item from list
- Admin Menu new tab external link
- Access to “My Site” is missing from the admin bar
- missing admin bar and widget in a template
- Add Admin Option w/ Anonymous Function
- add menu page in loop menu order
- Load admin bar without wp_head or wp_footer [duplicate]
- Issue with search form admin panel after PHP migration
- WP Admin Bar – Get current theme name as custom menu title
- how to use php in custom toolbar form
- admin menu naming
- How to call a certain object/menubar in a PHP file
- Add Woocommerce Customers link to custom admin menu
- How to access admin menu labels and links on front-end?
- Function won’t run onclick using Ajax
- Exclude specific post from displaying
- Update postmeta after theme switch
- Update post title from external file?
- Parse error: syntax error, unexpected end of file
- Troll the hackers by redirecting them
- PHP in CSS file?
- How would I use this filter to change the output of the date format to “Twitter time”?
- WP Business Directory Manager Plugin Admin Listings?
- Putting php inside an echo php shortcode
- Add login hyperlink to secondary navigation menu
- WordPress import media error
- Warning: Illegal string offset on theme options page [closed]
- How do I get an external php page to load using javascript
- Help getting previously visited pages ID
- How do I create a numbered list with PHP? [closed]
- Why in my theme I can’t see all the statics content under the posts?
- Woocommerce display one random product via php
- Display all pages – in order
- What does $_GET[‘iphone’] do?
- Change url tag name
- Backend of the WordPress.com [closed]
- Conditional using get_the_ID() not working [closed]
- Appended comments but they show up above the content instead of below
- get_template_directory adding FTP root folders in urls
- Custom ajax call returns 0 [duplicate]
- How to solve Woocommerce Memory Limit
- Metabox Not saving data
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Hide image if taxonomy term is empty
- Fatal error: Call to undefined function register_new_user()
- Shortcode to find and replace URL
- Remove the More Link
- Why is my str_replace not working on short code submitted by front-end?
- Detecting if parent page has gallery
- Skip foreach loop
- Displaying posts based on category
- stripping tags from excerpt in WordPress is not working
- Prev/Next Links Broken on Static Front Page Pagination
- Pagination broken on is_front_page()
- Changing the color scheme based on the url visited
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Mixing variables into an array when inserting values
- Don’t show certain div on front page?
- Could use some help with Shortcodes
- How to integrate noimage picture in this code
- Javascript not loading on certain page
- Location of core code for database connection and get_header
- Deleting Certain terms from appearing on the front end as links
- get comment data using comment id
- meta box not display data input in the textarea
- Clickable image link sends people to wrong URL
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- php include not working in custom page
- How to modify the default feed via a function
- How do I display offsite database info on my wordpress site?
- Styling the second sidebar
- first instantiated SimplePie object cosumes 5mb?
- Adding a line of text to php code
- If ‘editor’ is empty, then
- Different Subdomain changes page content
- Theme not calling Jquery properly
- customize wordpress database error page
- Removing the comment function within wordpress
- Creating Database Table vs. Adding MetaData to Post & User
- Post’s ID pattern?
- Countdown to date function?
- Include text in echoed hyperlink
- How to put a form with php code into a variable or shortcode?
- Utilize Function in Child Theme / Template File