How to Remove the RSD Link from Your WordPress Site

Home » Snippets » How to Remove the RSD Link from Your WordPress Site
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

When optimizing your WordPress site for performance or security, you might come across advice to remove the Really Simple Discovery (RSD) link that WordPress automatically includes in your site’s header. What is the purpose of the RSD link and how might it affect your site? And if you decide to remove it, how do you go about this task? We explain all this and provide concise, step-by-step instructions for removing the RSD link in this article.

					function wpturbo_remove_rsd_link() {
    remove_action( 'wp_head', 'rsd_link' );
}
add_action( 'after_setup_theme', 'wpturbo_remove_rsd_link' );
				

Continuing with our tutorial, the provided code snippet defines a new function called wpturbo_remove_rsd_link(). This function is designed to remove the Really Simple Discovery (RSD) link that is typically outputted to the header of your WordPress site’s HTML.

This RSD function is utilized for the purpose of service and API discovery which simplifies external access to your blog. However, if you do not use or need such a feature, you can use this code snippet to safely remove it from the header.

function wpturbo_remove_rsd_link() {
    remove_action( 'wp_head', 'rsd_link' );
}

Inside this function, we are invoking the remove_action() function, a native WordPress function used to remove specified actions that have been added to a specific action hook.

We are specifically targeting the rsd_link function that has been hooked to the wp_head action hook. The wp_head action hook is part of the WordPress core and is triggered within the head tag on the HTML document that gets generated on a WordPress page.

By removing this rsd_link action from the wp_head hook, we prevent the RSD link from being outputted within the head tag.

But, just defining this function is not enough to put the functionality into effect.

add_action( 'after_setup_theme', 'wpturbo_remove_rsd_link' );

We use the add_action() function, another native WordPress function, which adds a function to a specific action hook, to attach wpturbo_remove_rsd_link() to the after_setup_theme action hook. The after_setup_theme action is triggered after the theme is loaded but before any template file execution. This ensures that the wpturbo_remove_rsd_link() function is triggered to remove the rsd_link from the wp_head action hook right after the theme setup.

So, the entire process results in preventing the RSD link from being added to the head tag in the generated HTML. As an outcome, you should no longer see the RSD link in your website’s HTML head tag once the code is activated.

Register an account to save your snippets or go Pro to get more features.