How to add custom link on wordpress admin sidebar without using plugins? For example, i want to add "Google.com" link. How should i do this?
I tried this: Added next code to admin-bar.php
function mycustomlink() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'parent' => 'new-content',
'id' => 'mycustomlinkId',
'title' => __('Custom link'),
'href' => admin_url( 'google.com'),
'meta' => false
));}
And added next code to class-wp-admin-bar.php
add_action( 'admin_bar_menu', 'mycustomlink', 900 );
but no results.
To add a new link, go to your WordPress admin area > Links > Add New. There, fill in the name of the link and its description, choose its category (create a new category if needed), configure the target, link relationship and advanced settings to your preference.
Upon activation, go to Settings » Adminimize page and look for Admin Bar Backend Options and Admin Bar Front End Options tabs. Clicking on each of them will take you to the admin bar options where you can select which items to display in WordPress admin bar. You can also choose items visible to each user role.
Add this to the bottom of your theme's function.php
add_action( 'admin_menu', 'linked_url' );
function linked_url() {
add_menu_page( 'linked_url', 'External link', 'read', 'my_slug', '', 'dashicons-text', 1 );
}
add_action( 'admin_menu' , 'linkedurl_function' );
function linkedurl_function() {
global $menu;
$menu[1][2] = "http://www.example.com";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With