There are times where you don’t need to <head> tag to be cluttered with things you just don’t need.
WordPress adds a number of meta tags to the <head>
section of your website which in many cases is not needed, or can even help prevent bots and hackers getting information about your site that can aid them in making your life a bit more difficult than you would like.
What You Need
- FPT software (Filezilla is a good one)
- A text editor (notpad++ and Sublime Text are great free editors)
Downloading the Necessary File
First thing we will need to do is download the functions.php file for your WordPress theme. To do this you will need your FTP software. If you don’t have FTP credentials, you can find or add new ones by logging into your hosting control panel, or by contacting your hosting provider
When making changes to a themes code, it is recommended to do this on a Child Theme, so when your theme is updated by the theme author, your edits won’t be affected or wiped out.
Finding the functions.php file
The functions file is located in your theme (or child theme) folder which can be found here: wp-content/themes/your-them-name/functions.php
Once you have located the file, download it to your computer.
Editing The functions.php File
Now that you have the file, it’s time to edit it, so go ahead and open it up in your favourite text editor (mine is Sublime Text, in case you are wondering).
Each of the following code snippets will remove something from the <head>
of your website that can help with SEO or keep hackers or bots at bay!
The first piece of code removed the version of your WordPress install.
<meta name="generator" content="WordPress 5.0" />
This helps to prevent hackers from figuring out whether you have updated your WordPress install. Why is that important? It’s important because older versions of WordPress tend to have vulnerability, and most updates are patched to fix these, but, if you don’t update to the latest version, leaving the version number in your <head>
tag will let hackers know which version you have making it easy for them to locate an easy way to make a mess of your website.
This code removes that tag.
remove_action('wp_head', 'wp_generator');