When a site running WordPress loads there’s quite a lot of code in the <head> that some would argue is useless information.
The most publicised of these is the WordPress Generator meta tag which lists you are running WordPress and the WordPress version number.
It’s arguable this is a potential WordPress security issue, although it’s a way for potential hackers to find WordPress blogs running out of date versions of WordPress there’s plenty of other ways hackers can find an out of date WP install: the readme.html file for example (try loading https://stallion-theme.co.uk/readme.html ), won’t load because I delete it after each update, try it on your site and you’ll see something like this:
So even if you remove the WordPress meta generator tag there’s other ways hackers can determine your site is running WordPress and the version. Anyway, I digress, this article isn’t specifically about WordPress security.
WordPress Meta Generator Tag
In most WordPress themes in the <head> they will output code like this:
<meta name="generator" content="WordPress 3.9.1" />
This code is generated when a theme includes the WordPress hook wp_head() within the <head> section of a template file (usually the header.php template file).
You can view what’s in the head of your site by going to your WordPress blogs home page in FireFox or Google Chrome and View Source.
The problem with this is broadcasting the version number of WordPress is a potential security issue, especially if you tend not to update WordPress on a regular basis. Basically as a version of a particular software program (like WordPress ages) hackers are more likely to discover serious security flaws in the code of older versions (no software is 100% secure).
When a version of WordPress is found to have a security issue hackers will scan the Internet for websites running that version of WordPress and if your site broadcasts the WordPress version number and you haven’t updated WordPress quickly enough, you may find your site is hacked and ruined!!!
When I first discovered this (2008ish) I tried removing wp_head() from a theme, but the wp_head() hook is important for other reasons, so you can’t just remove it, you have to selectively tell WordPress NOT to load that particular function when WordPress loads and that’s easily achieved at template level by adding this to your templates function.php file (could also add it to a plugin).
<?php remove_action('wp_head', 'wp_generator');?>
Try adding this to the very bottom of your functions.php file, if it doesn’t work try at the very top.
Cleaning the Head Code of WordPress
The wp_head hooks loads a bunch of functions, some of which can safely be removed on many WordPress sites.
Examples include: Really Simple Discovery (RSD) link, Windows Live Writer link and Post relational links.
remove_action wp_head Really Simple Discovery Links
This is the sort of code that’s displayed in the head:
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://domain.com/xmlrpc.php?rsd" />
This is the link used by XML-RPC clients, basically it’s used for integrating a WordPress site with other services like the Flickr API. If the site isn’t integrated with any other services, you can safely disable this code.
<?php remove_action('wp_head', 'rsd_link');?>
remove_action wp_head Windows Live Writer
This is the sort of code that’s displayed in the head:
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://domain.com/wp-includes/wlwmanifest.xml" />
If you don’t use Windows Live Writer to edit your WordPress site you should be able to safely disable this.
<?php remove_action('wp_head', 'wlwmanifest_link');?>
remove_action wp_head ShortLink
This is the sort of code that’s displayed in the head:
<link rel='shortlink' href='http://www.domain.com/?p=1' />
This is a link to the non permalinks version of a post. Can’t think of a reason why we’d want a link like that in the head?
Remove with:
<?php remove_action('wp_head', 'wp_shortlink_wp_head');?>
remove_action wp_head Index Relational Link
This is the sort of code that’s displayed in the head:
<link rel='index' title='Home Page' href='http://www.domain.com' />
It’s a link to your home page of the WordPress installation. Browsers like FireFox will preload these pages.
Remove with:
<?php remove_action('wp_head', 'index_rel_link');?>
remove_action wp_head Start Relational Link
This is the sort of code that’s displayed in the head:
<link rel='start' title='Your first Post' href='http://www.domain.com/first-post/' />
It’s a link to your first post. Browsers like FireFox will preload these pages. Seriously WordPress developers, what’s the likelihood the very first post someone made is going to be loaded by a visitor next, there’s probably not even a link to that page on most pages of a reasonable size blog?
Remove with:
<?php remove_action('wp_head', 'start_post_rel_link');?>
remove_action wp_head Previous and Next Relational Link
This is the sort of code that’s displayed in the head:
<link rel='prev' title='Previous Post' href='http://www.domain.com/previous-post/' />
<link rel='next' title='Next Post' href='http://www.domain.com/next-post/' />
It’s a link to your previous and next posts. Browsers like FireFox will preload these pages. Unless you have the previous and next links added to your theme it seems to be a waste of time loading these pages in advance. I could understand this concept with paged archive pages like Categories, but not on WordPress posts or pages.
Remove with:
<?php remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');?>
Stallion Theme Usage
All the above WP remove actions are available within the Stallion WordPress SEO theme and Stallion Responsive theme.
The screenshot above shows the WP remove_actions options under the Stallion Responsive Performance Options page (“Stallion Theme” >> “Performance Options”).
David Law
WordPress Page Load Speed
Thanks for these – I’m always on the look out for ways to improve page load speeds. I’m finding a lot of gems on your site BTW – I’m building my own theme and trying to make sure I max out the SEO.
WP Init Hooks
Thanks! I was seeing init hooks being called twice and it took me forever to figure out why until I noticed the “next” link and tried commenting out the wp_head function in the header.
WordPress White Screen Error
Hi i jus add a tag :
on the end of my site and boom now its white complete white
can i get my site back and how?
i long in on wordpress painel but every thing is white how can i fix it?
How To Fix WordPress White Screen
WordPress white screen normally means you’ve broken some PHP code.
Revert the code you changed to what it was before the change.
If you worked online with the WordPress editor and you can’t login to to your Dashboard.
Either reupload the unedited theme files using FTP (Filezilla for example) over the ones you changed or download the file you changed, edit it in a text editor and reupload.
If you theme is called Redback Theme there will be a folder under:
something like
Download the /redback/ folder (whatever your theme is called) to your PC, there you can edit the files and reupload.
If online you edited functions.php edit it on your PC, remove the broken code and reupload.
If you have the original theme files you can upload the entire folder over the folder you broke.
If still not working the last resort is delete the theme you have active by going to
And delete the entire folder /redback/ (your theme folder).
By deleting the active (broken) theme folder, WordPress will activate the default TwentyFourteen theme and you can again login to your Dashboard.
Make sure there’s a folder /twentyfourteen/ at
otherwise WordPress won’t have the default theme to activate.
Obviously if you are reading this a year or more from when I wrote it and WordPress has a new default theme (TwentyFifteen would be my next guess) make sure the default theme is present.
You’ll be able to log back in and reinstall whatever theme your were using and broke.
For future reference when editing theme files do it on your PC so you can have multiple backups, upload the changed file one at a time via FTP, if a change breaks your site it’s an easy case to upload the unedited file.
David Law
How To Fix WordPress White Screen
Removing WP Next and Previous Posts Links
Hi David,
Can you help me understand how to remove the Next links and the previous links which comes on every post. I read on some of the sites including this that we have to insert this code on functions.php file:
I am not a techie and only handle wordpress a little bit from its dashboard. I would really appreciate if you could tell me where exactly to put this line of code. I mean after which line and before which line on functions.php file?
Thanks.
Rajesh Iyer
Removing WP Next and Previous Posts Links
Edit WordPress Functions.php File
Like anything in life it’s easy when you know how :-)
Although you can edit the WordPress theme functions.php file under your Dashboard: can pretty much assume all WordPress themes today (2014) have a Functions.php file.
If you make a code mistake that breaks the theme (white screen of death) you won’t have access to the Dashboard WordPress Theme Editor (accessed via “Appearance” >> “Editor”) since you’ll be locked out of the Dashboard by the code error and will either have to use FTP or a control panel to either fix the file or delete the themes folder (that forces WordPress to use the default WP Twenty Fourteen theme).
For this reason it’s advisable to use an FTP program like Filezilla (it’s free) so you can edit the file in a text editor (Notepad will do), upload the edited functions.php file via FTP and if you made a mistake upload the original functions.php file (obviously keep a backup of the unchanged file) fixing your code error.
You’ll find your functiosn.php file at:
However you decide to add code (if it’s the WordPress theme editor be careful) to the functions.php file it usually works at or very near the end.
Some functions.php files end with:
If this is what your themes functions.php files last line looks like it makes sense to enclose whatever code you are adding within a opening and closing PHP tag like this and add it on the final line after the last ?> :
If your themes functions.php doesn’t end in
Means the PHP code doesn’t end as such.
In this case add the code as is like this (so no <?php and ?> bits):
For both examples it’s important not to add extra blank lines or spaces (white space) after the code you’ve added, can cause some issues with your RSS Feeds if there’s white space in PHP files (messes up feeds, not sure why). Basically don’t add your PHP code and a bunch of carriage returns or spaces after.
Sounds a lot more complicated than it is, edit file, copy and paste code at the bottom, access site via FTP program and upload the editing functions.php file over the current file, see if it works. Takes about 3 minutes when you know how, takes less time in the online theme editor, but make a code error and, DOH!
David
Edit WordPress Functions.php File
Re: Edit WordPress Functions.php File
Thanks a ton David for your detailed reply. I will take a back up of my files first and try the FTP method. I will update you about the result soon.
Thanks.
Rajesh Iyer
Re: Edit WordPress Functions.php File
Hi David,
I did exactly as you described. I used the Coffee Cup FTP through which I first took back up of whole site. Then I made the changes in the functions.php file. Added those 3 lines after the last but the next & previous links still show. Can I email you and give you my website details? I use the Solostream theme of WPVideo.
Thanks for your help.
Regards,
Rajesh Iyer
Re: Edit WordPress Functions.php File
Remove Post Relational Links from WordPress
Glad you figured out how to use FTP, can be a sticking point for those new to website development.
I don’t log into other users websites other than to try to fix issues with my own WordPress themes and then only on rare occasions (99% of the time the fixes are easy).
This is the exact code I use in the Stallion Responsive SEO theme package to remove Post Relational Links:
Looking through the code you originally posted could be the formatting, sometimes copying and pasting from one website and into a comment changes the ” and ‘ characters which breaks the code. The ‘ should be the character you should see on your keyboard under (same key) the @ sign.
I’ll update my comment above with code I know works (didn’t really look at the code, just copied yours) after sending this.
David
Remove Post Relational Links from WordPress
WordPress Next and Previous Post Links
Hmm, you might be asking the wrong question.
When you say remove the “Next and Previous Posts Links” do you mean when viewing source of your websites code you see something like this near the top of the code (in the head):
If so those next and prev rel links (relative links) are removed by this code
If you mean your WordPress theme adds at the top or bottom of the content a link you can click on to the next and previous posts, the above code has no impact on those clickable links.
They will be hard coded into your themes template files. Each WordPress theme is different, but if it’s on the single blog post pages the code might be in the themes single.php file.
Look for code like this:
If you delete the “posts_nav_link();” code it should remove the next and previous links.
If it’s not in single.php use a text editor like Notepad++ (it’s free) to do a “Search in files” search for
posts_nav_link
Will list where the code is located, could be anywhere, in function.php as part of a function or as part of a part template file.
I consider these potentially SEO damaging links, unless a website is fully niched (only covering one niche) adding two links to the next and previous WordPress post could be adding unrelated links to an article, which is why the above function isn’t part of Stallion Responsive.
No SEO value to a website targeting several distinct niches if they randomly interlink, this post for example is about WordPress, I wouldn’t want it automatically linked to the make money posts or my off topic blogging posts.
David
WordPress Next and Previous Post Links
Re:WordPress Next and Previous Post Links
Hi David,
First of all, I really thank you for taking time out and helping me out. I really appreciate it.
I did a search for ‘posts_nav_link’ and it was found in a file called bot-nav.php under the theme’s main folder. There are 16 lines of code in that file and it is as under:
Please tell me what lines to exactly delete?
Again, thanks a ton mate!
Rajesh Iyer
Re:WordPress Next and Previous Post Links
Adding HTML/PHP Code to WordPress Comments
To add HTML/PHP code to a WordPress comment you have to put it between code tags, otherwise WordPress strips it to prevent comments looking a mess:
<code>
Add PHP/HTML Code Here
</code>
Doesn’t always work, this isn’t built into WordPress core, so is a Stallion Responsive theme feature, but it can be a little funky at times.
If I didn’t have this feature the code I’ve posted earlier would have been stripped by WordPress or shown as a mess.
David
Adding HTML/PHP Code to WordPress Comments
WP Next and Previous Post Links
Ok, trying again:
Please tell me which lines to remove?
Thanks again.
Rajesh
WP Next and Previous Post Links
WordPress Navigation Links
Looks like the code is used for the WordPress single page next and previous links and the next and previous links for archives (categories navigation etc…).
Top is for single, bottom archives, either delete the reference to this file on single.php
Or change the code you posted to:
That deletes the next/prev links from single.php posts only leaving the archive next/prev links in place.
David
WordPress Navigation Links
Editing WordPress Template Files
In your WordPress themes single.php you’ll probably have a line of code like this:
Based on bot-nav.php is probably just the code for the next and prev links removing the above line from single.php would remove the next and previous links.
Alternatively emptying the bot-nav.php (delete everything within it). though if the code is used for other next and previous links, they’ll be gone as well.
I note the WordPress theme you mentioned earlier is a premium theme: WP Video Theme from Solostream (you paid for it). Don’t they have a support system for this sort of stuff?
David
Editing WordPress Template Files
Removed WordPress Next and Previous Post Links
Hi David,
I removed that line from single.php and it worked!! So glad to have finally figured it out. A million thanks to you.
Regarding the theme I use, you are right. It is a paid theme. I did have one issue earlier and I posted in their support forum. But before they answered, I had done a few tweaks and had got it fixed. You are right though, I should be using their support more often.
That said, I am surely going to change my theme in near future as my content increases. I shall be bookmarking your site and shall come back to you when the time is right.
You are a champ!!
Rajesh
Removed WordPress Next and Previous Post Links