How to Add a New Custom Link in WordPress Sidebar

WordPress is quite famous for its flexibility and advancements. Even more, WordPress provides a friendly and powerful admin panel to manage the content on the website. Besides, WordPress supports further customization of the admin panel.

WordPress admin panel has two main parts, the first one is a sidebar and the second one is the main container. The sidebar is the WP admin panel’s main navigation, and it lists all the available functionalities, including plugins, themes, settings, etc.

What if we want to add a new link to the sidebar? The answer and its implementation both are quite simple and easy to implement.

Add New External Link to WP-Admin Sidebar

To add a custom link to your wp-admin sidebar, follow the below steps.

First, open wp-admin and go to the theme editor.

After that, copy and paste the below code in the functions.php file of the active WordPress theme.

Read Also: Custom Session in WordPress

CODE

add_action( 'admin_menu', 'linked_url' );
function linked_url() {
  add_menu_page( 'linked_url', 'NEW LINK TITLE', 'read', 'my_slug', '', 'dashicons-list-view', 1 );
}

add_action( 'admin_menu' , 'linkedurl_function' );
function linkedurl_function() {
  global $menu;
  $menu[1][2] = "LINK";
}

Explanation

We added a new external link in the wp-admin sidebar in the above code at the first position.

Conclusion

I hope the above code will add a new external link to your wp-admin panel. WordPress provides much more advancements to help users with an effortless experience.

Enjoy Coding πŸ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *