How To Clean Up Unnecessary Code From WordPress Header Without Plugins

PHPProgrammingWordPress

How To Clean Up Unnecessary Code From WordPress Header Without Plugins

How To Remove Weblog Client Link

Example:

<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.example.com/xmlrpc.php?rsd" />
To remove the EditURI/RSD link from WordPress header, paste the below code into your theme’s function.php.

remove_action ('wp_head', 'rsd_link');

How To Remove Windows Live Writer Manifest Link

Example:

<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://www.example.com/wp-includes/wlwmanifest.xml" />
To remove the wlwmanifest link from WordPress header paste the below code into your theme’s function.php.

remove_action( 'wp_head', 'wlwmanifest_link');

How To Remove WordPress Generator (Version)

Example:

<meta name="generator" content="WordPress 4.6.1" />
To remove WordPress Generator from WordPress header paste the below code into your theme’s function.php.

remove_action('wp_head', 'wp_generator');

How To Remove Page/Post Shortlinks

Example:

<link rel='shortlink' href="http://www.example.com/?p=175">
This is the URL shortening feature provided by WordPress, but if you do no use this url, it is best to remove it from the header. To remove page/post shortlinks from WordPress header paste the below code into your theme’s function.php.

remove_action( 'wp_head', 'wp_shortlink_wp_head');

How To Disable REST API Link – api.w.org

Example:

<link rel='https://api.w.org/' href='http://www.example.com/wp-json/' />
To remove REST API Link – api.w.org from WordPress header paste the below code into your theme’s function.php.

remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );

How To Disable oEmbed Discovery Links and wp-embed.min.js

Example:

<link rel="alternate" type="application/json+oembed" href="https://example.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fexample.com%2Fpath%2F"/>

<link rel="alternate" type="text/xml+oembed" href="https://example.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fexample.com%2Fpath%2F&#038;format=xml"/>

<script type='text/javascript' src='https://example.com/wp-includes/js/wp-embed.min.js?ver=4.4.2'></script>
oEmbed discovery links are added from WordPress 4.4. oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly. Also Read : How to Create a Table in SQL – Postgres and MySQL Example Query To remove oEmbed discovery links and wp-embed.min.js from WordPress header paste the below code into your theme’s function.php.

remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );remove_action( 'wp_head', 'wp_oembed_add_host_js' );

remove_action('rest_api_init', 'wp_oembed_register_route');

remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);

How to Remove RSS Feed Links

Example:

<link rel="alternate" type="application/rss+xml" title="WDV &raquo; Feed" href="https://example.com/feed/" />

<link rel="alternate" type="application/rss+xml" title="WDV &raquo; Comments Feed" href="https://example.com/comments/feed/" />
To remove RSS feed links and wp-embed.min.js from WordPress header paste the below code into your theme’s function.php.

remove_action('wp_head', 'feed_links', 2 );
       

Advertisements

ads