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 use nonce with front end submission form?
- How to export/import theme customizer settings?
- How to loop through JSON data in wordpress WP REST API
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Drop down+sort blog posts date added/most popular
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- WordPress Customizer: How can you have multiple active callbacks on one control?
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- wordpress custom endpoint multiple params
- Enable errors PHP WordPress 5.2
- Class ‘WP_Widget’ not found
- Second Navigation inside header
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- How to insert a local image with custom size
- how to trace notice warning on core function is_page() & is_singular in class-wp-query.php
- A function that returns true when the Author is a certain role is_author(admin)?
- Add a class to the anchor tag on HTML5 gallery
- get_term_link() returns incorrect url
- Conditional Header in wordpress
- Display a specific category of products in shop page and disable code for specific actions
- Cannot access wp-admin (wordpress dashboard)
- Trying to build simple deposit code that hooks into woocommerce
- Get children post mime type using parent post_ID wp_post
- Is it better to store images and other files in the root directory or the theme directory
- Use .php file as page instead of wordpress page & template file?
- PHP include is only working in certain places in my custom WP theme
- How to get post permalink url without a href
- Find hours between post_date and post_date_gmt
- Preg_Match(): compilation failed unknown property name
- Convert the_permalink() function output into string
- Fatal error: Uncaught Error: Call to undefined function get_header() [closed]
- get_current_site() is undefined
- Incrementing PHP variable onclick to display posts by month
- Use variable in SQL statement
- writing an unique php function to be used on my website
- Using Custom Value Options in PHP
- Get options from database using php class
- Problem in replacing the_content with the_excerpt()
- Output product category link from WP_Query
- Adding onload to body for certain pages
- Additional file upload in Gutenberg page options/featured image
- Change wordpress’ database data using ajax – how to get current user id?
- Add css class to string
- How to block specific user id in custom login form?
- Dropdown Category form. Only show Sub-Categories
- Passing a value from an input field to a php function in WordPress?
- Display all categories including sub categories under a list ul
- WP Hook Before a post is created
- Store user form submitted information in post type
- Block that renders html saved in a php file
- WordPress files break if I edit them, but adding a closing PHP tag fixes it
- $_GET[‘title’] in WordPress
- Can’t update or install plugins in WordPress, php unidentified index
- Offset with ajax load more posts duplicates
- Efficient way of querying for a “fallback” post?
- Shortcode in a $output statement
- WP Redirect with user nickname/username
- If else statement based on referral URL
- Archive page if else not working for post_excerpt and post_content
- add bootstrap modal after login in wordpress
- Hide sharing box and author box with a metabox on WordPress
- WordPress Website Featured Image Replacement Issue
- syntax error unexpected ‘}’ at 364 line
- get_post_meta no longer working
- 500 error when using wp_upload_dir() [closed]
- How to use plugins_url() inside PHP stylesheet file [duplicate]
- Using Excel formula in PHP. Use ^ symbol [closed]
- PHP warning Invalid argument supplied for foreach() on custom page template
- Assign new post author IF another user in custom field on post transition
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- How to limit the number of posts in the wordpress loop in conjunction with the “download more” button?
- WordPress Query – Blog Cards Duplicate issue