How to Remove WordPress Meta Generator tag
I was reading an excellent post How to Stop Your WordPress Blog Getting Hacked. In that, the author has listed out different ways on how you can stop your WordPress Blog getting hacked.
The second point in that post is to “Remove Meta Generator Tag”. This tag reveals the WordPress Version you are using. This is the reason to remove that tag.
As instructed, I headed to header.php
of my current theme and looked for the following line to remove it.
<meta name="generator" content="WordPress 2.7" />
I was surprised to see that line was not there but, it was getting generated when i view the source of my Blog.
I then found a way to Remove WordPress Meta Generator tag.
If you look the contents of header.php
carefully, you will find a function call wp_head()
just before tag. This is the function which is adding WordPress Meta Generator Tag.
Our aim is to remove that tag from getting generated by wp_head()
function.
Following steps are to remove meta generator tag in wordpress:-
- Login into your wordpress as administrator privilege
- Go to Appearance -> Editor and click on the file
functions.php
- Add this line before the line with ?> (make sure you are not adding it in any function) and click Update
- If you don’t find
functions.php
, then you need to create one with the content below and upload to your theme folder:- - Save the file.
- Clear the cache if you using any caching plugin, Load your blog and check the source code.
remove_action(’wp_head’, ‘wp_generator’);
<?php remove_action(’wp_head’, ‘wp_generator’); ?>
I hope the above steps helped you to remove WordPress Meta Generator Tag.
You may want to read more WordPress tweaks and hacks:
How to Beautify Code samples in your post using Syntax Highlighter
How to implement Threaded Comments in WordPress Themes
How to Add categories to Nav Bar
How to add Comment Link in Single Post – WordPress
How to Add WordPress pages to Nav Bar
1924 readers are already subscribed to this blog! Why don't you be one of them? Subscribe to this blog via your favorite RSS feed reader or by entering your email address on the form below: |
This is great, thank you
Hey Nihar, I read the very same post. It was pretty good wasn’t it? I followed several of the steps and will get to some of the other ones later.
@Sire, I think i discovered that post from your site only 🙂
You see, and people say that there is nothing of value to be found on my blog 😉
@Sire, Why are you saying that?
I was only kidding Nihar, that’s why I put 😉 at the end of the comment. Everyone knows that I occasionally come up with a good post. 😀
hey nihar,Does it Works for codium Extend theme. i m using this theme and unable to find out the meta generaator tag.
I do not have the WP version showing in my code but I also do not have the code you mentioned in my functions.php. Somehow I managed to get rid of this in some other way. My problem is that I just cannot remember how I did it. Strange but true.
@Lyndi,
It is really strange. I am gonna wait for you, If you find the reason you let me know. May be there is some other way that these two ways…
Maybe there is some differences between different versions of WodPress.
Thanks a lot for writing this. I was aware of this, but being as lazy as I am..I just kept putting if off. Getting rid of that tag right now.
I guess being hacked once didn’t teach me a lesson.
@Pallab,
Get rid of it. Its always good to be play safe.
Hi there,
thanks for the information. I know this is off topic, but I have given you an award. Please go and see what award you have received from me.
Thanks again 🙂
@George,
I checked the award, Thanks for it…
Not a problem, enjoy your day 🙂
@Nihar
You always come up with something new.i didnt know about this thing.I should get rid of this code asap.
@Ricky,
Thanks for the appreciation.
Well I am using a plugin for this thing. I know this method but it is not working always.
@Tech, Oh is it. Can i know which plugin are you using?
i love how easy it is to alter wordpress with a few simple clicks. thanks for being so helpful.
@Dug, yes. It is very flexible.
It helps to keep away the amateur hackers, who may be using the version number for a simple hack…. but ultimately…. if a good hacker comes along… this modification won’t stop them. I am just saying… because I am now in my 3rd year at College for Software Engineering, and I learned alot from my professors, not about hacking… but in regards that no system is ever 100% secure. I mean this comment in a good way.
Till then,
Jean
@Used Tires, I agree with you but, one has to make sure that he/she has tried to secure the blog.
I be soon get rid of it
very effective solution
working, thanks