Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add custom link on wordpress admin sidebar

Tags:

wordpress

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.

like image 735
Daler Avatar asked Oct 11 '16 13:10

Daler


People also ask

How do I add a link to my WordPress sidebar?

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.

How do I customize the admin bar in WordPress?

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.


1 Answers

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";
    }
like image 158
yayheartbeat Avatar answered Nov 15 '22 21:11

yayheartbeat