Clean up and Optimize WordPress Header Code

Notice a lot of extra code that appears unnecessary or “junk” in your website’s page source? As an advocate of clean and minimal page code ( pro-SEO, to some extent ) I like to optimize every single piece of code and keep things as clean and efficient as possible.

Let’s look at some of that seemingly unwanted stuff and an easy way to get rid of them.

Unnecessary junk in WordPress site’s header

Here’s an example of a WordPress website’s header with those extra rel, or meta lines of code. Each of these lines has a purpose. I, however, do not find value in the rel tags and their purpose and clean them up first thing post a fresh install. While that may be the case with you; take some time to understand what each line does and feel free to follow the steps to clean them all (or some).

unnecessary code in wordpress header

Let me explain a few of them:

Really Simple Discovery (RSD)

I’m talking about the code that generates this line in your WordPress blog:

<link rel="EditURI" type="application/rsd+xml" title="RSD" href="" />

This is an XML format and a publishing convention for making services exposed by your blog discoverable by client software. If you’ve no idea what this is, probably you’re not going to use it for connecting client software to your blog.

WP Generator

This displays the version of WordPress you’re using.

<meta name="generator" content="WordPress 5.4.1" />
Post Relational Links

Post relational links are, as the name suggests, the information about the relationship with some other pages. I didn’t really see a huge benefit from them.

Similarly, there are tags related to Feed Links and other stuff that aren’t really something useful to the vast majority of websites. However, there are some tags you shouldn’t remove, such as:

Canonical Tag

I would recommend you retain the canonical tag that outputs something like this:

<link rel="canonical" href="" />

Canonical tags help avoid duplicate content issues with SEO. It helps search engines understand identical content under different URLs and helps them better index one version of the multiple available. We will not remove that.

Here’s the code snippet you need to place in your theme’s functions.php file. Paste the code in a new line after the beginning <?php

//BEGIN Remove Junk From Header - 
remove_action('wp_head', 'rsd_link'); // remove really simple discovery
remove_action('wp_head', 'wp_generator'); // remove wordpress version
remove_action('wp_head', 'feed_links', 2); // remove rss feed links
remove_action('wp_head', 'feed_links_extra', 3); // removes all rss feed links
remove_action('wp_head', 'index_rel_link'); // removes link to index page
remove_action('wp_head', 'wlwmanifest_link'); // remove wlwmanifest.xml
remove_action('wp_head', 'start_post_rel_link', 10, 0); // remove random post link
remove_action('wp_head', 'parent_post_rel_link', 10, 0); // remove parent post link
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // remove the next and previous post links
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 ); // remove shortlink
remove_action('wp_head', 'rest_output_link_wp_head', 10);// Disable REST API link tag
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);// Disable oEmbed Discovery Links
remove_action('template_redirect', 'rest_output_link_header', 11, 0);// Disable REST API link in HTTP headers
//END Remove Junk From Header - 

There might be additional pieces of “junk” you don’t like bloating up the page code. One such block of code is related to how Emojis are displayed on your website. If you don’t care about or your blog doesn’t use of a lot of emojis, you should follow the instructions to remove emojis code from WordPress head; and remove those pieced of code as well.


Just like with everything else with WordPress, you could instead use a plugin to clean up the unnecessary code from your WordPress site’s HEAD. However, I would rather follow the steps above and minimize the use of 3rd-party plugins on your website for these petty things. After all, a lean and clean website is all we want right?

Did you encounter other possible lines of unwanted code in the WordPress header? Or, need help cleaning things up a bit more? Let us know in the comments below.

188 Comments on “Clean up and Optimize WordPress Header Code”

  1. Asking questions are in fact nice thing if you are not understanding something totally, but thispost offers fastidious understanding yet. Kirstyn Rafaello Hett

  2. Thanks , I’ve just been searching for information about this subject for ages and yours is the greatest I have came upon till now.
    However, what in regards to the conclusion? Are you sure about the supply?

  3. Very great post. I simply stumbled upon your weblog and wished to say that I’ve really loved browsing your blog posts.
    After all I will be subscribing to your feed and I hope you write again soon!

  4. Hello there, You have done an incredible job.
    I will certainly digg it and personally recommend to my
    friends. I’m confident they will be benefited from this web

  5. Hey There. I discovered your weblog the use of msn. This is a really neatly written article.
    I’ll make sure to bookmark it and return to learn more of your helpful information. Thanks for
    the post. I’ll certainly return.

  6. You’re so awesome! I don’t believe I’ve truly
    read through anything like that before. So nice to find somebody with some unique thoughts on this topic.
    Really.. many thanks for starting this up.
    This site is something that is required on the internet, someone with a bit of originality!

  7. Hi everyone, it’s my first pay a quick visit at this website, and piece of writing is in fact fruitful in support of me, keep up posting
    such articles or reviews.

  8. I’ll immediately clutch your rss feed as I can not
    find your e-mail subscription link or e-newsletter service.
    Do you’ve any? Kindly permit me know in order that I could subscribe.

  9. I have to thank you for the efforts you’ve put in penning this blog.

    I am hoping to see the same high-grade content from
    you in the future as well. In fact, your creative writing abilities has encouraged
    me to get my very own blog now 😉

  10. One of the best ways to find out the needs and requirements
    of customers is to be in direct contact with each of them, and Instagram provides this direct connection. Business owners are able to communicate with their customers directly and without intermediaries by using Instagram and
    take steps to develop their products and services. If you
    are looking for a cheap and fast way to increase your activity on Instagram, do
    not worry because Social-Store, with the cheapest and fastest way, has made it possible for you to multiply your
    activity on Instagram. The Social-Store support team is ready to provide you any services about social networks, including
    increasing your Instagram followers, increasing your
    Instagram likes and increasing your Instagram views and other social networks
    at 24 hours of a day and at 7 days of a week.
    Our site also provides you with the best and most secure payment ways such as Bitcoin,
    PayPal and etc. So that you can easily use the services of the Social-Store site wherever you are in the world.
    Social-Store is easy to use and easy to payment. So log in to our site and
    easily use the guaranteed services of Social-Store.

  11. Wow, marvelous blog layout! How lengthy have you ever been blogging for?
    you make running a blog look easy. The overall glance of your site is fantastic, as
    neatly as the content material!

  12. Good day very cool web site!! Man .. Excellent ..
    Superb .. I’ll bookmark your website and take the feeds also?
    I’m happy to search out so many helpful information right here within the submit,
    we want work out more strategies on this regard, thanks for sharing.
    . . . . .

  13. Hey! I know this is kinda off topic but I was wondering if you knew
    where I could get a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having difficulty finding one?
    Thanks a lot!

  14. Do you have a spam issue on this blog; I also am a blogger, and I was wanting to know your situation; we have created some nice practices and we
    are looking to swap strategies with others, be sure to shoot me an e-mail if interested.

  15. This is really interesting, You are a very skilled blogger.

    I’ve joined your rss feed and look forward to seeking more of
    your magnificent post. Also, I have shared your website in my social

  16. Fantastic goods from you, man. I’ve be aware your stuff prior to and you are just extremely excellent.
    I actually like what you have got right here, really like
    what you’re stating and the way in which wherein you say it.

    You make it entertaining and you continue to care for to keep it wise.

    I can’t wait to learn far more from you. That is actually a tremendous web site.

  17. you’re really a good webmaster. The website loading pace
    is incredible. It sort of feels that you are doing any distinctive trick.
    Furthermore, The contents are masterpiece. you have done a wonderful process on this topic!

  18. Hi, Neat post. There’s a problem together with your website in web explorer,
    would test this? IE still is the marketplace chief and a large element of other people will
    pass over your excellent writing due to this problem.

  19. There are many solutions to attempt finding your true self, one of these is actually connecting with ourselves physically through self-massage.
    This means the man will not want or need to go to nap after sex.
    Research has demonstrated that nurturing touch boosts
    the launch of oxytocin, a hormone that produces a feeling of nurturing and sensation of trust.

  20. Thanks for one’s marvelous posting! I quite enjoyed reading it, you may be
    a great author.I will remember to bookmark your blog and
    will come back sometime soon. I want to encourage you
    to definitely continue your great posts, have a nice holiday weekend!

  21. Hello there! This is my first visit to your blog! We are a
    team of volunteers and starting a new initiative in a community in the same niche.

    Your blog provided us beneficial information to work on. You have done a marvellous job!

  22. I do agree with all of the ideas you’ve presented for your
    post. They are very convincing and can definitely work.
    Still, the posts are very short for beginners. May just you please extend them a little
    from subsequent time? Thanks for the post.

  23. After going over a few of the blog articles on your website, I honestly like
    your way of writing a blog. I book-marked it to my bookmark website list and
    will be checking back soon. Take a look at my website too
    and let me know your opinion.

  24. The hard drive where his Bitcoin password has simply two chances left to.
    Yet with many observers and billionaire Mike Novogratz responded with a considerable slowdown in two days.
    We know what’s Cryptocoin mining is that bear markets will not
    assist exporters. Massachusetts mutual life in August 2018 the
    continuous drop within the mainstream financial sources and know what.

    Oxygen could not use Core in in the future alone in August of.

    Palmer notes in a single location to a network impact that
    could be a digital asset. An establishment were a minimal learning curve which is why the worth
    of 1. Why is there can by no means make sure that transaction fees are assured
    for spectrocoin Bitcoin debit card. I ended the yr 2017
    can easily be termed as frenemies of Bitcoin. 29,000 for the yr Steve Keena update.
    Traders will pay is hiding a. Most accounts shall
    be totally different methods of alternate options
    which can be emailed to you might have been.

  25. whoah this weblog is magnificent i like reading your articles.

    Stay up the great work! You realize, many persons are looking
    around for this information, you could aid them greatly.

  26. Nice post. I learn something totally new and challenging on sites
    I stumbleupon on a daily basis. It will always be
    helpful to read articles from other authors and practice something from other websites.

  27. Hey there! I’ve been following your blog for a long time now and finally got the bravery to go ahead and give you
    a shout out from Dallas Tx! Just wanted to say keep up the good job!

  28. We still cannot quite assume that I made it worse often be kind of staring at the important points seen on your blog post. Our grandkids and i also are sincerely thankful with regards to your generosity plus giving me possibility pursue our chosen profession path. Document information and facts I became of the web-site. Ruthie Charlie Mack

  29. Loved the podcast and I relate so much because I am a Pilates teacher and movement therapist, but also Wellness Coach which is the business I am growing and want to build more. Wilona Virgil Johny

  30. Hey there I am so grateful I found your weblog, I really found you
    by error, while I was looking on Aol for something else,
    Regardless I am here now and would just like to say thanks for a incredible post and a all round thrilling blog (I
    also love the theme/design), I don’t have
    time to read through it all at the minute but
    I have bookmarked it and also included your RSS
    feeds, so when I have time I will be back to read a great deal more, Please
    do keep up the great work.

  31. Okay, I admit it. You have captured my interest. I do not usually upload talk about blog sites, yet you have earned it. I have a newfound interest in this subject as well as can not wait to see even more blog posts from you in the future. Thank you for supplying a lot details in a single blog post! Netti Loydie Sands

  32. A formidable share, I simply given this onto a colleague who was doing somewhat analysis on this. And he in actual fact purchased me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If potential, as you turn into experience, would you mind updating your blog with extra particulars? It’s highly useful for me. Massive thumb up for this weblog post! Eva Reinaldo Scrogan

  33. wonderful points altogether, you just gained a brand new reader. What would you suggest in regards to your post that you made a few days ago? Any positive? Rhetta Teddie Winikka

  34. Eu ut id pariatur laboris culpa. Aliqua esse magna labore mollit eu magna aliquip labore. Cillum occaecat esse duis laboris deserunt enim occaecat magna. Arielle Boot Tiernan

  35. If you are like many people, you have trouble sleeping
    many nights no matter how hard you try. You may have tried other methods to stay asleep, and these may include other meds and even natural methods.

    Now you can buy sleeping tablets online and get the well-deserved
    rest you need!

    Sleeping tablets are hypnotic sedatives. For this reason, you should take this medication according to your doctor’s instructions.
    Sleeping medication is not to be used every single night.
    It is supposed to be used to treat short-term insomnia.
    Long-term sleeping issues will require a different
    method of treatment.

  36. We stumbled over here by a different page and thought I might as well check things out. I like what I see so now i am following you. Look forward to checking out your web page for a second time.| Tatiania Joey Gabbi

  37. Excellent pieces. Keep writing such kind of info on your blog.
    Im really impressed by your blog.
    Hi there, You have performed an incredible job. I’ll certainly digg it and for my part suggest to my friends.
    I am sure they will be benefited from this web site.

  38. Excellent post. Keep writing such kind of information on your
    site. Im really impressed by your blog.
    Hi there, You’ve done an incredible job. I’ll certainly digg it and in my opinion suggest to my friends.
    I’m sure they will be benefited from this site.

  39. naturally like your website but you have to take
    a look at the spelling on several of your posts. A number of them are rife with spelling problems and I in finding it
    very troublesome to tell the reality nevertheless I
    will certainly come again again.

  40. I really like your blog.. very nice colors & theme. Did you design this website
    yourself or did you hire someone to do it for you?

    Plz respond as I’m looking to design my own blog and would like to know where u got this
    from. cheers

  41. Very nice post. I just stumbled upon your weblog and wished to say
    that I have really enjoyed surfing around your blog posts.
    In any case I’ll be subscribing to your rss feed and I hope you write
    again soon!

  42. Hello! I know this is kind of off topic but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having trouble finding one? Thanks a lot!|

  43. Hey there! Do you know if they make any plugins to assist with Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Thank you!|

  44. I seriously love your blog.. Pleasant colors & theme. Did you build this site yourself? Please reply back as I’m wanting to create my own blog and want to learn where you got this from or what the theme is called. Thanks!|

  45. Hey I know this is off topic but I was wondering if you
    knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some
    experience with something like this. Please let me know
    if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

  46. I am extremely impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it’s rare to see a nice blog like this one today.|

  47. It’s perfect time to make some plans for the long run and it’s time to be happy. I’ve learn this post and if I may I wish to recommend you few fascinating things or suggestions. Perhaps you could write next articles regarding this article. I desire to learn even more things about it!|

  48. İnstagram Takipçileri
    İnstagram hesaplarını, kurumsallaşmak, markalaşmak ya da pazarlama işlerinin artırılabilmesi için kullananlar,
    takipçi sayılarını artırarak hedeflerine ulaşabiliyorlar.
    Firma tüm İnstagram kullanıcılarına takipçi paketlerini 100 takipçi sayısı ile 50.000 takipçi sayısı arasına değişen paketlerden oluşmaktadır.

  49. My brother suggested I would possibly like this blog. He used to be entirely right. This put up truly made my day. You cann’t believe just how so much time I had spent for this info! Thank you!|

  50. It’s amazing to go to see this web page and reading the views of all friends about this paragraph, while I am also zealous of getting knowledge.
    ps4 games 185413490784 ps4 games

  51. Cool blog! Is your theme custom made or did you download it from somewhere?

    A design like yours with a few simple tweeks would really make
    my blog jump out. Please let me know where you got your design. With thanks

  52. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that
    automatically tweet my newest twitter updates. I’ve been looking
    for a plug-in like this for quite some time and was hoping maybe you would have some experience with
    something like this. Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new

  53. Can I simply say what a comfort to discover somebody who really understands what they are talking about on the internet. You certainly realize how to bring an issue to light and make it important. More people ought to look at this and understand this side of your story. I was surprised you’re not more popular given that you definitely possess the gift.|

  54. Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your weblog? My blog site is in the very same area of interest as yours and my users would certainly benefit from some of the information you provide here. Please let me know if this okay with you. Thanks!|

  55. whoah this blog is excellent i love studying your articles. Keep up the good work! You realize, a lot of persons are searching around for this info, you could help them greatly. |

  56. Hi there, I believe your blog could be having internet browser
    compatibility problems. Whenever I look at your site in Safari,
    it looks fine but when opening in Internet Explorer, it has some overlapping issues.
    I simply wanted to give you a quick heads up! Besides that, wonderful website!

  57. Hello would you mind letting me know which web host you’re using? I’ve loaded your blog in 3 completely different internet browsers and I must say this blog loads a lot quicker then most. Can you recommend a good hosting provider at a fair price? Thanks a lot, I appreciate it!|

  58. Somebody essentially lend a hand to make seriously articles I would state. This is the very first time I frequented your website page and up to now? I amazed with the analysis you made to make this particular put up extraordinary. Fantastic activity!|

  59. Thank you for any other informative blog. Where else may just I am getting that kind of info written in such a perfect approach? I have a challenge that I’m just now working on, and I’ve been at the glance out for such information.|

  60. I’m not sure exactly why but this website is loading incredibly slow for me.
    Is anyone else having this problem or is it a problem on my end?
    I’ll check back later and see if the problem still exists.

  61. What i don’t understood is in fact how you’re not really much more neatly-liked than you may be now. You’re very intelligent. You already know therefore significantly relating to this matter, made me for my part believe it from numerous various angles. Its like men and women are not involved unless it’s one thing to do with Girl gaga! Your personal stuffs excellent. At all times care for it up!|

  62. Does your site have a contact page? I’m having problems locating it but, I’d like to send you an email. I’ve got some creative ideas for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it grow over time.|

  63. I just couldn’t go away your website before suggesting that I really enjoyed the standard info an individual supply in your guests? Is gonna be back often in order to investigate cross-check new posts|

  64. Woah! I’m really enjoying the template/theme of this site. It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between superb usability and appearance. I must say you’ve done a superb job with this. Also, the blog loads very quick for me on Chrome. Exceptional Blog!|

  65. Good day! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this article to him. Fairly certain he will have a good read. Thanks for sharing!|

  66. I was wondering if you ever thought of changing the layout of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?|

  67. After looking over a handful of the blog articles on your web page, I really appreciate your technique of writing a blog. I book marked it to my bookmark site list and will be checking back soon. Please check out my web site too and let me know how you feel.|

  68. certainly like your website but you have to test the spelling on several of your posts. Several of them are rife with spelling problems and I in finding it very bothersome to inform the truth on the other hand I will certainly come again again.|

  69. I must thank you for the efforts you have put in writing this blog. I am hoping to check out the same high-grade blog posts from you in the future as well. In fact, your creative writing abilities has inspired me to get my own website now ;)|

  70. hi!,I like your writing so so much! proportion we keep in touch extra about your post on AOL? I need an expert on this space to resolve my problem. Maybe that is you! Having a look forward to peer you. |

Leave a Reply

Your email address will not be published. Required fields are marked *