Get all our 20+ Elementor themes worth $609 at just $59! Limited time offer. Get It Now

WordPress Website Templates

Find Professional WordPress themes Easy and Simple to Setup

inner banner

How to Fix WordPress Posts Returning 404 Error

Are your WordPress posts returning 404 error? Don’t know why this is happening and how to fix this issue? Read our detailed guide and learn how to quickly and easily fix this problem.

We will explain in detail why this happens, and provide multiple ways to solve it. Regardless of what causes this error on your blog, our guide will provide a solution to this painful problem.

First, you should know that you’re not alone. Posts with 404 error are a very common problem among Wordpress users along with 500 internal server error. It can be often caused by a minor change but can take some time to fix, especially if you’re just a beginner.

Unless you are using the services of a professional web design company such as CyberCraft, you will have to solve this issue yourself. Before we explain how to solve it, let’s try to understand what causes this error.

What Causes WordPress Posts 404 Error?

The most common cause of this error is when the .htaccess is accidentally deleted or missing. Another cause may be incorrect rewrite rules. Besides, there might be some other unknown causes or some issues with plugins or themes.

Regardless of which cause you are dealing with, known or unknown, we are going to provide you with a detailed algorithm for identifying and removing the causes of 404 error once and forever. Let’s get started!

5 Ways to Solve WordPress Posts 404 Error

Which method is correct depends on every specific case. Our step-by-step by algorithm will allow fixing this issue quickly and easily. Here are the steps you should take:

  • Fix permalinks
  • Make .htaccess file writeable
  • Make sure .htaccess has correct WordPress permissions
  • Check if your theme is causing the error
  • Deactivate all plugins and check if there’s a plugin which causes this problem

Most likely, the first or second step is all it takes for most people to fix this error. But even if those don’t help, proceed to the next steps until you solve the error. Let’s analyze each of the steps in detail.

Fix Permalinks

A permanent, never-changing URL to a post, page, etc. is called a permalink. It must not be identical to any other existing link. By default, WordPress permalinks consist of a post’s ID.

It is possible to change the format of permalinks, for instance, to include the date of publication, title, etc. These types of links are called pretty permalinks.

However, there are some things which can prevent permalinks from functioning as they should which may result in 404 error. For instance, this occurs when Apache’s mod_rewrite function is not working. Resetting permalinks may help to fix this problem with Apache.

Go to the “Permalinks” section in “Settings”. Select the “Plain” option and hit “Save”. After that, activate the previous permalinks settings and click “Save” again.

For custom post types, if two or more custom post types have an identical slug or title you’re going to encounter 404 error. Therefore, fix this issue and make sure it never happens again. Check if the 404 error has disappeared. If it has not, proceed to the next step.

Reset .htaccess File

The .htaccess file can be found at your web site’s root. You can use FTP, cPanel, command line, SSH to access it. You can either download it and make the necessary edits in a text editor and then upload it substituting it for the old file or edit it directly.

We would advise making a full backup of your website before making any changes of this kind. If you’ve never made any changes to the .htacess file you can simply delete and click “Save” in the “Permalinks” section of “Settings”. WordPress will create a new .htaccess file from scratch then and you won’t have to make any edits.

Otherwise, replace the following code with the current one in your .htaccess file (if you have a single installation of WordPress):

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

However, if you’re running your WordPress website on a subdomain insert the following code:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

Also, in case we’re dealing with a subdirectory installation insert this code instead:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

If you’re running WordPress 3.4 or any older version, check this htacesss reference guide by WordPress Codex. Once you’ve updated your .htaccess code, the 404 error should disappear. If this didn’t help move on to our next step.

Make Sure .htaccess Has Correct WordPress Permissions

If the previous steps do not work, examine if your .htaccess file works with correct permissions for WordPress. You want to set permissions for this file to 644.You can do this via cPanel or FTP. Alternatively, you can try doing this with SSH:

find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} \;

Check If Your Theme Is Causing the Error

If you still have no success, deactivate your current theme and enable WordPress’ classic Twenty Seventeen. Go to the “Themes” section of “Appearance”, find Twenty Seventeen and click “Activate”. Check if the 404 error is still there. If it is gone, then it’s the theme you were using which caused the error. Otherwise, proceed to the next step.

Deactivate All Plugins

Sometimes a certain plugin may be causing all sorts of problems with your WordPress website. Therefore, if none of the previous methods helped you, go to “Plugins”, select all of them, and click “Deactivate”.

Check if the 404 error is still in place. If it disappeared, reactivate each plugin one by one, and check if the error appears between each activation. Once the error appears again after activating another plugin, that’s the one which caused it.

Final Words
Just as the 404 error on posts is one of the most common WordPress issues, so it is easy to solved. There are five well-known ways to fix this issue, all of which we have described in detail in this guide. Now it’s your turn to apply our guide in practice. Good luck:)

Dan Goldman Author

Dan Goldman is a full-time writer at a Ukrainian software company CyberCraft Inc. which provides offshore software development services at a low cost to clients all over the world.