TechTipsApp

Technology tips blog

  • Articles
    Categories
    • Tech news
    • Internet
    • Social Network
    • Google
    • Geeky Tips
    • Android
    • Windows 10
    Top Posts
    • Install Windows XP from USB
    • Install Windows 7 from USB
    • Open Facebook When It's Blocked
    • Partition Hard Drive Without Formatting
    • Reset Windows 7 Password
    • About
    • Contact
    • Privacy policy
    • Advertise
    • Terms of Conduct & Copyright Policy

How to Fix 404 Soft Errors in WordPress To Avoid Google Penalty

Tanmay WordPress Leave a Comment

Being the most popular CMS (Content Management System), WordPress is still not completely out of fault. One such faulty part of WordPress is the 404 Soft Error pages. Did you know that this 404 Soft Error can invite a Google penalty for your website or blog? If not, read how to fix 404 Soft Errors in WordPress to avoid Google penalty.

What is 404 Soft Error?

According to the Google Webmaster guidelines, a page with 404 Soft Error is actually the page which has no content but the server does not returns a 404 HTTP response for the page. Just because you show a “404 Not Found” text into the content part of the page does not mean that it is a 404 page. Rather, you should call it as a 404 Soft Error page until it returns a 404 status code as the server response. Learn more about 404 Soft Error from Google Webmaster Tools Help Page.

When does 404 Soft Error Happen in WordPress?

The 404 Soft Errors happen with WordPress mostly in two cases:
Case 1. If you search something that does not exist at a WordPress site using the WordPress internal search feature, it returns a page saying “Sorry, there is no content matching with your search query” or some thing like that. Even, in some theme, it shows “404 Not Found” against any non-existing search query.
404-soft-error-wordpress-internal-search
But if you see into the server response code, you will get a 200 OK response for that search result page instead of 404 Not Found. It is not recommended by Google, as the crawlers can not decide that the page does not exist.
Case 2. If you have any category(s) or tag(s) without having any post, the link for those categories or tags returns the 404 Soft Error page. Y0u can take the “Uncategorized’ category as an example. If you browse http://www.yourdomain.com/category/uncategorized/, you should get the page where the result is empty but the server response is 200 OK.
404-soft-error-wordpress-category
Why does Google Charge Penalty to the Sites having 404 Soft Error Pages?
Google always prefers to show relevant pages to the visitors. If any of your pages does not exist that the visitors are searching for, you should return a 404 Not Found page with a 404 Not Found server response. If you do not follow this; for instance, if you redirect them to your home page or somewhere else or you show an empty page without proper server response code, you are actually not maintaining the Google Webmasters Guidelines. This may invite a Google penalty for your site.
Some SEO experts suggest to block search pages from search engines. But we do not inspire you to do so. Blocking search boats can damage your site more deeply.
How to find if my site has 404 Soft Errors?
You can find the 404 Soft Error page from Google Webmaster Tools. Sign into your Webmaster account and go to Crawl > Crawl Errors from the left pane. Now you can find the “Soft 404” tab at the right-hand side. Head to that tab and you can see all the 404 Soft Error pages are listed there.
Click on any item and you will be given the details.
webmaster-tools-crawl-error-soft-404

How to Fix 404 Soft Errors in WordPress

As I stated earlier that WordPress generates 404 Soft Errors for its internal searches (for non-existing query) and the archive pages which do not have any post, here is how to convert those Soft Error pages into proper ‘404 Not Found’ pages.
You can do it by adding a small snippet of codes at your themes function.php template and calling the function from the Search and Archive page template. I have written the code for Genesis child themes though. Those who are using Genesis child theme can add the following codes directly into their child theme’s function.php file. The others can modify this code slightly to implement with non-Genesis themes.

function force_to_404()
{
if ( have_posts() )
{
return FALSE;
}
header( 'HTTP/1.0 404 Not Found' );
$GLOBALS['wp_query']->is_404 = TRUE;
return TRUE;
}
function oxh_404soft(){
echo genesis_html5() ? '<article class="entry">' : '<div class="post hentry">';
printf( '<h1 class="entry-title">%s</h1>', __( 'Not found, error 404', 'genesis' ) );
echo '<div class="entry-content">';
if ( genesis_html5() ) :
echo '<p>' . sprintf( __( 'The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it by using the search form below.', 'genesis' ), home_url() ) . '</p>';
echo '<p>' . get_search_form() . '</p>';
else :
?>
<p><?php printf( __( 'The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it with the information below.', 'genesis' ), home_url() ); ?></p>
<?php
endif;
echo '</div>';
echo genesis_html5() ? '</article>' : '</div>';
}
// Force 404 Soft Errors to 404 Not Found Errors
add_action('get_header','oxh_soft_404');
function oxh_soft_404(){
if(is_search()){
if ( force_to_404() ) {
remove_action( 'genesis_before_loop', 'genesis_do_search_title' );
add_action( 'genesis_loop', 'oxh_404soft' );
return; //here it will stop any further process so soft 404 will not occur
}
}
elseif(is_archive()){if ( force_to_404() ) {
add_action( 'genesis_loop', 'oxh_404soft' );
return; //here it will stop any further process so soft 404 will not occur
}
}
}

Once you configured your WordPress by above way, you can check the results for which the 404 Soft Error pages were getting generated.
The Screenshot for WordPress internal search result page with non-existing search query.
404-not-found-wordpress-internal-search
The Screenshot for WordPress category page(Uncategorized) which do not have any post.
404-not-found-wordpress-category
Hope this helps you fix the 404 Soft Error problem with your WordPress site.
Useful WordPress Tutorials
1. Show Last Modified Date For The Posts in Genesis.
2. How to Optimize and Defer Javascript in WordPress.
3. P3 Plugin Review.
Is your site free of 404 Soft Errors? – Do share with us.

Post Tags: Code, Genesis, Google, Search Engine, Theme
Similar Articles from This Blog
How to Create Custom Theme on Windows 10
How to Create Custom Theme on Windows 10
How to View Posts from Specific People or Pages on Google+
How to View Posts from Specific People or Pages on Google+
Google Play Gift Cards Available in India!
Google Play Gift Cards Available in India!
Google Unveils New Convertible Chromebook Chromebit Stick With Asus
Google Unveils New Convertible Chromebook Chromebit Stick With Asus
Top 10 Meta Search Engines to Get More Search Result
Top 10 Meta Search Engines to Get More Search Result
How to Sign Up Google Apps Work Referral Program In India
How to Sign Up Google Apps Work Referral Program In India

Comments

  1. Ajay :

    Hello,
    Very Good article. Thanks!
    I am new to php. Can you please give the universal code for other users?

    Reply

Leave a Comment Cancel reply

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

About Us

Tech Tips App is a technology blog, looking forward to broaden the mental horizons of technical geeks round the web. Striving hard to quench your technical thirst, we have put our best efforts on the line of exhaust to satisfy your versatile technical vocabulary.

Recently Published

  1. Partitioning Hard Drive in Windows 7 Without Formatting
  2. How to Find My Contacts on Google Map
  3. Introducing SMS Organizer by Microsoft is the Best SMS App
  4. How to Fix Windows Update When It Gets Stuck
  5. How to Get Rid of Windows 10 Automatic Repair Loop [Solved]
  6. Best Antivirus for Windows 10 (Is Windows Defender Good Enough?)
  7. Best Facebook Messenger Bots to Get more out of Messenger
  8. How to Fax a Document From Your Smartphone
  9. Top Social Media Platforms You Should Always Know About
  10. Bitcoin vs Altcoin: Where to Invest? – Guide For Dummies

© 2021 Tech Tips App All Rights Reserved  Post Sitemap