creating a WordPress child theme here<\/a>.<\/p>\n\n\n\nThat's all you need to do to clean up the header.<\/p>\n\n\n\n
None of these changes are permanent, so as soon as you remove the code from functions.php<\/em>, the lines will return.<\/p>\n\n\n\nWe'll end up with a header that looks like this:<\/p>\n\n\n\n
<\/figure><\/div>\n\n\n\nPlease note I truncated the inline style in this image, for clarity.<\/p>\n\n\n\n
Read on for a more detailed explanation on how to clean up the WordPress header.<\/p>\n\n\n\n
How to remove WordPress Feed Links<\/h2>\n\n\n\n Different pages will have different feed links on them.<\/p>\n\n\n\n
These used to be a lot more useful for blogs, back when people would use feed readers and subscribe to blogs.<\/p>\n\n\n\n
Now they're just legacy and don't really belong on your website.<\/p>\n\n\n\n
The feed links on a blog page look like this:<\/p>\n\n\n\n
<\/figure><\/div>\n\n\n\nThere is a general website feed, one for website comments and one for the comments on this page.<\/p>\n\n\n\n
In case it's hard to read, the feed code output is:<\/p>\n\n\n\n
<link rel=\"alternate\" type=\"application\/rss+xml\" title=\"Intelliwolf Example Site » Feed\" href=\"http:\/\/localhost\/demo\/feed\/\" \/>\n<link rel=\"alternate\" type=\"application\/rss+xml\" title=\"Intelliwolf Example Site » Comments Feed\" href=\"http:\/\/localhost\/demo\/comments\/feed\/\" \/>\n<link rel=\"alternate\" type=\"application\/rss+xml\" title=\"Intelliwolf Example Site » Next Post Comments Feed\" href=\"http:\/\/localhost\/demo\/2019\/12\/05\/next-post\/feed\/\" \/><\/code><\/pre>\n\n\n\nWe can get rid of that in two lines (because the first is a comment):<\/p>\n\n\n\n
\/\/ Remove Feed Links\nremove_action('wp_head', 'feed_links_extra', 3);\nremove_action('wp_head', 'feed_links', 2);<\/code><\/pre>\n\n\n\nCopy those lines into the functions.php<\/em> file of your Child Theme.<\/p>\n\n\n\nHow to remove WordPress Emoji code<\/h2>\n\n\n\n The WordPress Emoji code, also known as WordPress Smilies, is one of my bugbears.<\/p>\n\n\n\n
For such limited functionality (it literally just recognizes and displays emojis), it brings in a whole lot of JavaScript and CSS.<\/p>\n\n\n\n
It looks like this:<\/p>\n\n\n\n
<\/figure><\/div>\n\n\n\nIf you want to see the code in text, this is everything that's thrown in there, willy-nilly:<\/p>\n\n\n\n
<link rel='dns-prefetch' href='\/\/s.w.org' \/>\n<script type=\"text\/javascript\">\nwindow._wpemojiSettings = {\"baseUrl\":\"https:\\\/\\\/s.w.org\\\/images\\\/core\\\/emoji\\\/12.0.0-1\\\/72x72\\\/\",\"ext\":\".png\",\"svgUrl\":\"https:\\\/\\\/s.w.org\\\/images\\\/core\\\/emoji\\\/12.0.0-1\\\/svg\\\/\",\"svgExt\":\".svg\",\"source\":{\"concatemoji\":\"http:\\\/\\\/localhost\\\/demo\\\/wp-includes\\\/js\\\/wp-emoji-release.min.js?ver=5.3\"}};\n!function(e,a,t){var r,n,o,i,p=a.createElement(\"canvas\"),s=p.getContext&&p.getContext(\"2d\");function c(e,t){var a=String.fromCharCode;s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,e),0,0);var r=p.toDataURL();return s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,t),0,0),r===p.toDataURL()}function l(e){if(!s||!s.fillText)return!1;switch(s.textBaseline=\"top\",s.font=\"600 32px Arial\",e){case\"flag\":return!c([127987,65039,8205,9895,65039],[127987,65039,8203,9895,65039])&&(!c([55356,56826,55356,56819],[55356,56826,8203,55356,56819])&&!c([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]));case\"emoji\":return!c([55357,56424,55356,57342,8205,55358,56605,8205,55357,56424,55356,57340],[55357,56424,55356,57342,8203,55358,56605,8203,55357,56424,55356,57340])}return!1}function d(e){var t=a.createElement(\"script\");t.src=e,t.defer=t.type=\"text\/javascript\",a.getElementsByTagName(\"head\")[0].appendChild(t)}for(i=Array(\"flag\",\"emoji\"),t.supports={everything:!0,everythingExceptFlag:!0},o=0;o<i.length;o++)t.supports[i[o]]=l(i[o]),t.supports.everything=t.supports.everything&&t.supports[i[o]],\"flag\"!==i[o]&&(t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&t.supports[i[o]]);t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&!t.supports.flag,t.DOMReady=!1,t.readyCallback=function(){t.DOMReady=!0},t.supports.everything||(n=function(){t.readyCallback()},a.addEventListener?(a.addEventListener(\"DOMContentLoaded\",n,!1),e.addEventListener(\"load\",n,!1)):(e.attachEvent(\"onload\",n),a.attachEvent(\"onreadystatechange\",function(){\"complete\"===a.readyState&&t.readyCallback()})),(r=t.source||{}).concatemoji?d(r.concatemoji):r.wpemoji&&r.twemoji&&(d(r.twemoji),d(r.wpemoji)))}(window,document,window._wpemojiSettings);\n<\/script>\n<style type=\"text\/css\">\nimg.wp-smiley,\nimg.emoji {\n display: inline !important;\n border: none !important;\n box-shadow: none !important;\n height: 1em !important;\n width: 1em !important;\n margin: 0 .07em !important;\n vertical-align: -0.1em !important;\n background: none !important;\n padding: 0 !important;\n}\n<\/style><\/code><\/pre>\n\n\n\nYikes. Let's get rid of that.<\/p>\n\n\n\n
Put this code into the functions.php<\/em> file of your Child Theme.<\/p>\n\n\n\n\/\/ Remove Smilies\nadd_filter( 'emoji_svg_url', '__return_false');\nremove_filter('comment_text', 'convert_smilies', 20);\nremove_filter('the_excerpt', 'convert_smilies');\nremove_filter('the_content', 'convert_smilies');\nremove_action('wp_head', 'print_emoji_detection_script', 7);\nremove_action('wp_print_styles', 'print_emoji_styles');\nremove_action('admin_print_scripts', 'print_emoji_detection_script');\nremove_action('admin_print_styles', 'print_emoji_styles');\nremove_action('init', 'smilies_init', 5);<\/code><\/pre>\n\n\n\nThis is what that same section of the head looks like, without the emojis scripts:<\/p>\n\n\n\n
<\/figure><\/div>\n\n\n\nAh. Much better.<\/p>\n\n\n\n
How to remove the remaining WordPress Header code<\/h2>\n\n\n\n There are a number of other, miscellaneous items that WordPress brings into the header.<\/p>\n\n\n\n
The ones I'm talking about here look like this:<\/p>\n\n\n\n
<\/figure><\/div>\n\n\n\nThe code we'll be removing looks like this:<\/p>\n\n\n\n
<link rel=\"EditURI\" type=\"application\/rsd+xml\" title=\"RSD\" href=\"http:\/\/localhost\/demo\/xmlrpc.php?rsd\" \/>\n<link rel=\"wlwmanifest\" type=\"application\/wlwmanifest+xml\" href=\"http:\/\/localhost\/demo\/wp-includes\/wlwmanifest.xml\" \/> \n<link rel='prev' title='Hello world!' href='http:\/\/localhost\/demo\/2019\/12\/04\/hello-world\/' \/>\n<link rel='next' title='Last Post' href='http:\/\/localhost\/demo\/2019\/12\/06\/last-post\/' \/>\n<meta name=\"generator\" content=\"WordPress 5.3\" \/>\n<link rel='shortlink' href='http:\/\/localhost\/demo\/?p=8' \/>\n<link rel=\"alternate\" type=\"application\/json+oembed\" href=\"http:\/\/localhost\/demo\/wp-json\/oembed\/1.0\/embed?url=http%3A%2F%2Flocalhost%2Fdemo%2F2019%2F12%2F05%2Fnext-post%2F\" \/>\n<link rel=\"alternate\" type=\"text\/xml+oembed\" href=\"http:\/\/localhost\/demo\/wp-json\/oembed\/1.0\/embed?url=http%3A%2F%2Flocalhost%2Fdemo%2F2019%2F12%2F05%2Fnext-post%2F&format=xml\" \/><\/code><\/pre>\n\n\n\nTo do it in one fell swoop, add this code to the functions.php<\/em> file of your Child Theme, or read on to match each to an action:<\/p>\n\n\n\n\/\/ Remove Unneccessary Header Code\nremove_action('wp_head', 'rsd_link');\nremove_action('wp_head', 'wlwmanifest_link');\nremove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);\nremove_action('wp_head', 'wp_generator');\nremove_action('wp_head', 'wp_shortlink_wp_head', 10);\nremove_action('wp_head', 'wp_oembed_add_discovery_links');<\/code><\/pre>\n\n\n\nHow to remove the RSD Link<\/h3>\n\n\n\n \"RSD\" stands for \"Really Simple Discovery\". You might need to keep this line if you're using a remote service to post content to your website. If you're not doing that, you don't need this line.<\/p>\n\n\n\n
To remove the line:<\/p>\n\n\n\n
<link rel=\"EditURI\" type=\"application\/rsd+xml\" title=\"RSD\" href=\"http:\/\/localhost\/demo\/xmlrpc.php?rsd\" \/><\/code><\/pre>\n\n\n\nAdd this code to functions.php<\/em>.<\/p>\n\n\n\nremove_action('wp_head', 'rsd_link');<\/code><\/pre>\n\n\n\nHow to remove the WLW Manifest Link<\/h3>\n\n\n\n This line is only used by the Windows Live Writer application. If you're not using that, there's no reason to keep this line. To remove the line:<\/p>\n\n\n\n
<link rel=\"wlwmanifest\" type=\"application\/wlwmanifest+xml\" href=\"http:\/\/localhost\/demo\/wp-includes\/wlwmanifest.xml\" \/> <\/code><\/pre>\n\n\n\nAdd this code to functions.php<\/em>.<\/p>\n\n\n\nremove_action('wp_head', 'wlwmanifest_link');<\/code><\/pre>\n\n\n\nHow to remove the Previous and Next Links<\/h3>\n\n\n\n If you're running a gallery-heavy website, you might want to keep these lines to allow for preloading. Otherwise, you can get rid of them. To remove these lines:<\/p>\n\n\n\n
<link rel='prev' title='Hello world!' href='http:\/\/localhost\/demo\/2019\/12\/04\/hello-world\/' \/>\n<link rel='next' title='Last Post' href='http:\/\/localhost\/demo\/2019\/12\/06\/last-post\/' \/><\/code><\/pre>\n\n\n\nAdd this code to functions.php<\/em>.<\/p>\n\n\n\nremove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);<\/code><\/pre>\n\n\n\nIf your WordPress site hasn't been updated in awhile, this line is a shining beacon to any hackers as to what exploits they should use. To remove the line containing the WordPress version:<\/p>\n\n\n\n
<meta name=\"generator\" content=\"WordPress 5.3\" \/><\/code><\/pre>\n\n\n\nAdd this code to functions.php<\/em>.<\/p>\n\n\n\nremove_action('wp_head', 'wp_generator');<\/code><\/pre>\n\n\n\nHow to remove the WordPress Shortlink<\/h3>\n\n\n\n I've never understood what the purpose of the shortlink is supposed to be. To remove this line:<\/p>\n\n\n\n
<link rel='shortlink' href='http:\/\/localhost\/demo\/?p=8' \/><\/code><\/pre>\n\n\n\nAdd this code to functions.php<\/em>.<\/p>\n\n\n\nremove_action('wp_head', 'wp_shortlink_wp_head', 10);<\/code><\/pre>\n\n\n\nHow to remove the WordPress JSON Oembed Lines<\/h3>\n\n\n\n These lines allow other websites to do that nice looking WordPress embed. But I don't see a scenario where I want my website embedded in another.<\/p>\n\n\n\n
To remove these lines:<\/p>\n\n\n\n
<link rel=\"alternate\" type=\"application\/json+oembed\" href=\"http:\/\/localhost\/demo\/wp-json\/oembed\/1.0\/embed?url=http%3A%2F%2Flocalhost%2Fdemo%2F2019%2F12%2F05%2Fnext-post%2F\" \/>\n<link rel=\"alternate\" type=\"text\/xml+oembed\" href=\"http:\/\/localhost\/demo\/wp-json\/oembed\/1.0\/embed?url=http%3A%2F%2Flocalhost%2Fdemo%2F2019%2F12%2F05%2Fnext-post%2F&format=xml\" \/><\/code><\/pre>\n\n\n\nAdd this code to functions.php<\/em>.<\/p>\n\n\n\nremove_action('wp_head', 'wp_oembed_add_discovery_links');<\/code><\/pre>\n\n\n\nThat's all there is to it.<\/p>\n\n\n\n
After you've made the changes to functions.php<\/em>, make sure to clear any caches<\/a>, then reload your page to check everything's still working properly.<\/p>\n\n\n\nIf you notice any missing functionality that you want back, just go through this post again and see what you removed.<\/p>\n","protected":false},"excerpt":{"rendered":"
WordPress does a lot of things for us automatically. However, because it tries to be all things to all people, there are a few bits of code in the header that I always take out. Reducing the code can speed up the site and make it easier for a developer to see what’s actually important<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"yoast_head":"\n
How To Clean Up WordPress Head Code<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n