What Will I Learn?
- You will learn about the WordPress Generator Function causing WordPress version display.
- You will learn to use Wordpress's theme editor and edit
function.php
file. - You will learn to remove WordPress version number editing theme functions file.
Requirements
- A wordpress powered blog/website.
- Wordpress Admin Login Credentials.
- Little programming knowledge.(Optional)
Difficulty
- Basic
Tutorial Contents
Well, you must have heard or read about the potential security risk of showing your WordPress software version publicly.If you have ever searched about securing WordPress sites you must have read this many times because it is one of the most common WordPress security tips that every WordPress security expert talk about. Because by knowing your WordPress version hackers might attack your website from known vulnerabilities. So this is a good way to prevent such threats by disabling WordPress version number from the public eye, which has no use to show anyway.
To check this on your site, If you are on a google chrome browser just press Ctrl + U
on your keyboard while on any page/post of your WordPress powered blog, you can publicly see your WordPress version as:
<meta name="generator" content="WordPress 4.9.2" />
You can see this in the screenshot below which I have taken applying the same method from one of my WordPress powered blogs.
Generally, this is caused by the Generator meta tag caused by wp_hook which is located in the section of the header.php file within WordPress theme. By default WordPress, executes the wp_generator()
function whenever the hook wp_head()
is called.However this might is omitted by default in some of the themes, but most of the theme still has this tag generator function included.
Today, in this tutorial I want to show you how can we remove/disable WordPress version generator meta tag, by simply adding few lines of code inside your theme's function.php
file.
Before moving on, if you are starting your fresh blog I suggest you install a child theme and make all the changes on it. Because whatever changes you make on your core files will be overridden after the new updates.
You can access and edit your theme's function.php file in several ways. In this tutorial, I want to share probably the easiest way, editing function.php
from WordPress admin dashboard.
1. Login to Wordpress Admin dashboard and navigate to theme editor.
Login to your WordPress admin panel using your username and password. From the dashboard hover your mouse to the Appearance then from the sub-menu click on Editor button as shown in the figure below.
2. Open your theme's function.php
in the editor.
By default editor will be open will theme's Stylesheet style.css
. Now find function.php
on the right-hand side of the editor and click on it to open and edit this in the editor.
3. Add The Following code and update the file.
Now scroll to the end of the function.php
file and add the following code before the closing (?>) tag.
function remove_wordpress_version() {
return '';
}
add_filter('the_generator', 'remove_wordpress_version');
As you can see this function returns an empty string for the_generator
overwriting the default WordPress version.
Insert the code and click on the Update File button as shown in the figure below.
4. We can Also Disable this by adding the following line of code within the theme's function.php
.
Instead of above code from step 3 add the following code just before the closing tag.
remove_action('wp_head', 'wp_generator');
And Click on that Update File button as shown in the figure below.
That's it, if you have followed every step correctly this will remove the WordPress version generated by Generator Meta Tag. I have tried both of the methods and both worked well for me.So you can choose any one and switch to another if the first didn't work.
Curriculum
Here are some of my other WordPress tutorials you might like.
How to remove existing WordPress post revisions in database?
How to set your own automatic Trash emptying time in WordPress?
How to change the default Autosave Time Interval in WordPress?
How to disable XML-RPC in WordPress for better security enhancement without using a plugin?
How to Block Unauthorized Access to wp-config.php, Wordpress configuration file via .htaccess?
Disallowing Directory Browsing In Wordpress Via .htaccess File for Security Purpose.
How to Disable file editing(themes and plugins) feature within WordPress dashboard
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @katteasis I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I was looking an article on how to check WordPress version and found your blog with good resources. Thanks for your contribution!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit