Removing the Link Menu Item in WordPress Admin

Remember the Links Manager in WordPress? This was an option for us to add a custom post type or “link” in the admin interface, so that we could easily link to other websites as something popularised as a Blogroll. Nowadays it’s a somewhat outdated term, and for that reason the whole Links Manager component was hidden by default in WordPress 3.5 back in late 2012.

The component is still built into WordPress though and won’t show up by default on newer installations. Older installations that have been continually updated and containing links in the database however will still show this menu item even with newer versions of WordPress. Here’s what the menu looks like:

You may also find a “New Link” item at the top of the admin page, which lets you add a new link to your database if you like:

The question is, how do we remove these options, if they still show up in newer versions of WordPress? You’d think that deleting all links and link categories would be enough, but you may have tried and already found out that it is not.

In this article I’ll show you how to do this. I’ll also explain how to bring the Links Manager back if you ever need it.

Removing the Links Manager

There are two ways to do this: by updating the database, or by hiding the menu item. Let’s look at the latter first. Add this code to your functions.php file, refresh your admin page and you’ll notice the Links menu is gone.

/* remove links section in Admin Menu */
function guru_remove_links_menu() {
     remove_menu_page('link-manager.php');
}
add_action( 'admin_menu', 'guru_remove_links_menu' );

While this works fine, the option to add a new link when you hover over the top +New button will still be there. To eliminate that one too, we need to disable the whole module completely by setting a database value. The following added line of code will take care of it:

/* remove Links Manager module */
function guru_remove_links_module() {
     
     update_option( 'link_manager_enabled', 0 );
}
add_action( 'admin_menu', 'guru_remove_links_module' );

There’s no need to call this code more than once, as soon as “link_manager_enabled” is set to 0, neither the menu nor the add link option will show up anymore. Result!

Enabling the Links Manager

If you’ve grown attached to the little guy or have big plans for him, you can enable it even on newer installations of WordPress that have hidden it by default. We’ll call the reverse of the previous option, by setting “link_manager_enabled” to 1, like this:

/* enable Links Manager module */
function guru_enable_links_module() {
     
     update_option( 'link_manager_enabled', 1 );
}
add_action( 'admin_menu', 'guru_enable_links_module' );

Again, this code needs to be called only once to bring back the Links Manager. It’s not detrimental if you leave it in place, but hey every line of code not called makes the world a better place.

That’s it for today! There are other ways to accomplish this mission of course, and this WordPress Codex article as more solutions at the bottom. Enjoy, and happy hacking!

You can leave a comment on my original post.