Not complicated, but a little tricky to get timing right.
Something like this should work, but you might need to experiment with priority to get the link to specific position on the bar:
add_action( 'admin_bar_menu', function ( $wp_admin_bar ) {
if ( ! is_admin() ) {
return;
}
/** @var WP_Admin_Bar $wp_admin_bar */
$wp_admin_bar->remove_node( 'view-site' );
$wp_admin_bar->add_menu( array(
'id' => 'view-site',
'title' => __( 'Visit Site' ),
'href' => home_url( "https://wordpress.stackexchange.com/" ),
) );
}, 31 ); // After `wp_admin_bar_site_menu()` at 30.
Related Posts:
- How to hide menu on WordPress admin
- Show admin menu and toolbar in admin post page
- toolbar not visible on pages using front-page template
- WP components no style
- How to reference an existing css content-based icon, within my admin menu hook
- Margin problem on management menu?
- Different Admin language
- How to remove an item from menu bar’s +New menu based on User role
- How can I place a page link to the sidebar admin bar?
- How can I modify text in admin bar?
- How to include the admin bar?
- How to add admin bar only page?
- WordPress admin menu formatting issue
- Remove duplicate main – submenu in admin?
- Plugin View Details Link
- Getting custom admin submenu item to highlight when its active
- Add update notification bubble to admin menu item?
- remove_menu_page doesn’t work on custom plugin menus
- List table not rendering when $this->items is filled
- Modify Admin Bar Link
- Edit specific nodes in WP_Admin_Bar
- Order Admin sub-menu items?
- Admin sidebar items overlapping in admin panel
- How Can I remove or hide the export page in WordPress menu?
- Adding a menu item in the admin bar
- Add highlighting to new Admin Dashboard Menu Item
- Theme editor menu item refuses to go away
- How to remove the Plugins Editor from the admin menu
- Admin custom option screen not saved unless user manage_options capability
- WordPress admin menu formatting issue
- How to remove_menu_page added by a plugin that appears to have no referenceable slug
- Admin page menu keeps bugging out
- WordPress setting API strucked
- Hide Front-End Admin Bar Including 32 px Spacing
- Edit Page or Post from Top Admin Bar
- How to minimize WP dashboard menu programmatically?
- How to change menu page capability
- How to determin which admin screen/sub screen I’m currently viewing
- Add post-new.php?post_cat=catslug to admin menu
- Link to Second Level Admin Page
- check current_theme_supports in admin_menu hook
- Hide widgets/plugins from dashboard
- Admin page repeatable fields
- menu_order not working with slugs that start with admin.php
- How to add_menu_page include a php file page from theme directory
- How do I demote a menu item in the admin menu?
- Removing posts and comments from WordPress
- Is there a limit to the number of items that can be added using the Appearance Menus Screen?
- Remove All in One Pack from the admin bar
- Set different custom menu items for different user roles
- How to access $menu variable in custom .PHP file that loads wp-load.php?
- Role capability issue
- Adding a submenu to the Tools menu returns tools.php in a popup box
- WordPress admin menu formatting issue
- Create dynamic wordrpess blank page
- What’s the correct way of moving a menu page to a submenu
- Is it possible to add 3 level menu item to admin menu?
- Use Drag & Drop Functionality from WordPress Admin Area in the Frontend?
- Adding admin top-level menus
- Additional menu item popping in submenus
- Visiting a console submenu page does not expand its parent menu item
- How to align the top of an admin pointer to the target element?
- WordPress add page under admin submenu and retaining the active status of the parent submenu page in the menu
- Adding menu item to WordPress admin bar for editors to edit one plugin’s settings
- Remove Elementor Menu From WordPress Admin
- Moving Smush plugin menu position to media submenu and removing it from main menu
- update_option does not work in this scenario – how do I fix?
- How can I move Customizer menu item to first level in WP Dashboard?
- How do I disable certain menu in editor user administrator page
- How can I reorder admin bar items?
- Show limited menu to admin
- How can I change the admin menu title and url title on WordPress
- Creating an admin button that when clicked shows a popup form
- add sub_menu to a sub_menu (multiLevel sub_menu) in admin menu in wordpress
- Weird white space in admin area
- Linked pages not working with wordpress
- Hide admin menu items if it is empty
- How to add a notification next to custom admin menu?
- How to have submenus collapsed until they are clicked?
- When admin is logged in, admin-bar-rtl.min.css is not loaded on website view (the admin-bar is shown in the footer without CSS)
- admin menu: use default “general” page for theme settings using add_menu_page and add_submenu_page
- no themes or editor under appearance menu
- How to check an admin submenu already exists?
- wp_is_mobile() inside js
- Headers already sent error when creating multiple admin menu’s
- Simple CSS admin pagination
- Admin tabs for custom plugin
- Restricted access for other user roles
- Tab order of post admin page
- How Do I create multiple Top Level Admin Menu Pages To submit data to the options table?
- Add internal page to admin menu
- How can a left and right margin be added to the admin bar without access to “…wp-includes/admin-bar.php”?
- Settings API – Checkboxes validation in a menu with multiple subpages
- Hiding an added admin page menu using css
- Fatal error when using ‘#’ character as an admin menu link title
- How to create editable menu with parent and child in wordpress?
- How can I style my theme admin page?
- Admin menu links just refresh the page
- Responsive Admin Themes
- Admin menu link with variable