For a long time, I’ve been using several plug-ins to clean up some fields in WordPress Headers. In most cases, I would say that you don’t usually need a lot of information.
Why did WordPress add these features and links to your site?
well, the reason is obvious. WordPress is a very large CMS platform, used by more than 27% of online blogs. Each publisher has its own requirements. Some like to post articles onwp-admin
browser pages, some use third-party tools, and some use iOS or Android applications.
if you use the online version to post articles on your WordPress site, you should remove all unnecessary links from your WordPress site. What are the advantages of hiding
directory
?
- pages are certainly faster to load
- content code than to add
- your important website content is now slightly higher than the way search engines read
Let’s take a look at some links in WordPress Headers. The following steps will help you clean up and optimize the header section of your WordPress site.
1. Disable the XML-RPC RSD link
WordPress to addEditURI
to your website Header, which is required if you post articles through third-party tools. How to disable
? Add the following code to your theme functions.php file:
remove_action ('wp_head', 'rsd_link');
2. Deleting the WordPress version number
version number may expose your WordPress version information and give some premeditated people an opportunity. The code below
removes the WordPress version number from the site.
function crunchify_remove_version() { return ''; } add_filter('the_generator', 'crunchify_remove_version');
3. Delete the wlwmanifest link
if you are not writing in Windows Live Writer, you can remove the following content from the WordPress website Header.
adds the following code to your theme function:
remove_action( 'wp_head', 'wlwmanifest_link');
4. Delete short links
if you use other forms of fixed links, WordPress's default short links are completely meaningless and can be considered removed.
adds the following code to your theme function:
remove_action( 'wp_head', 'wp_shortlink_wp_head');
5. Remove query string from all static resources
static resource query string
add the following code, all query strings will be deleted.
function wbolt_cleanup_query_string( $src ){ $parts = explode( '?', $src ); return $parts[0];} add_filter( 'script_loader_src', 'wbolt_cleanup_query_string', 15, 1 ); add_filter( 'style_loader_src', 'wbolt_cleanup_query_string', 15, 1 );
note:
explore ('?', $src)
will delete everything after the?
symbol. If you only want to delete the query string for with ver, replace?
with?ver
.
6. 0. Disabling REST API's link connector
WordPress REST API enables CMS to communicate with other Web properties, no matter what programming language they are written in.
however, many websites don't use it, so in most cases, it's just unnecessary code. By default, the title of each site contains a link:
adds the following code to your theme function:
remove_action('wp_head', 'rest_output_link_wp_head', 10); remove_action('template_redirect', 'rest_output_link_header', 11, 0);
7. Removing the oEmbed embedding link
disabling embedding on a WordPress site does the following:
- it prevents others from embedding your site, and it also prevents you from embedding your site.
- removes oEmbed-specific JavaScript.
- disables filtering of oEmbed results.
- removes the oEmbed discovery link.
- turns off oEmbed auto-discovery.
- removes all embedded rewrite rules.
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
this is a complete code:
adds the following code to the theme's functions.php file, and everything is ready.
// ******************** Clean up WordPress Header START ********************** // function wbolt_remove_version() { return ''; } add_filter('the_generator', 'wbolt_remove_version'); remove_action('wp_head', 'rest_output_link_wp_head', 10); remove_action('wp_head', 'wp_oembed_add_discovery_links', 10); remove_action('template_redirect', 'rest_output_link_header', 11, 0); remove_action ('wp_head', 'rsd_link'); remove_action( 'wp_head', 'wlwmanifest_link'); remove_action( 'wp_head', 'wp_shortlink_wp_head'); function wbolt_cleanup_query_string( $src ){ $parts = explode( '?', $src ); return $parts[0]; } add_filter( 'script_loader_src', 'wbolt_cleanup_query_string', 15, 1 ); add_filter( 'style_loader_src', 'wbolt_cleanup_query_string', 15, 1 ); // ******************** Clean up WordPress Header END ********************** //