How to Fix WordPress Posts Returning 404 Error

How to Fix WordPress Posts Returning 404 Error

Despite being the most popular content management system in the world, you’ll occasionally run into errors when using WordPress — one such issue is WordPress posts returning a 404 error.

Fortunately, solving 404 errors in WordPress can be simple.

In most cases, they are caused by problems with your .htaccess file. This means once you re-configure or restore this file, the problem is solved.

In this tutorial, we’ll have a look at how to fix WordPress posts returning 404 error. Let’s get to it!

What Is a 404 Error in WordPress

404 errors aren’t unique to WordPress; they can happen with any type of website. These errors pop up when a page can’t be found. In many cases, browsers can’t find and access those pages simply because they don’t exist.

If your browser returns a 404 error because a page doesn’t exist, it’s usually a minor annoyance. However, in some cases, you may run into 404 errors for pages you know are there.

In these situations, the most common causes are as follows:

As such, if users are running into 404 errors on your website that are not caused by incorrect URLs, you’ll want to troubleshoot the issue as quickly as possible.

How to Fix WordPress Posts Returning 404 Error (3 Ways)

You’ll need an FTP (file transfer protocol) client such as FileZilla or Cyberduck to connect to your server. If you need help with setting up an FTP connection, here’s a great tutorial by WordPress Support on how to use FileZilla with WordPress.

To edit your WordPress files, you’ll need a text editor, such as Notepad, TextEdit, Atom, or Visual Studio Code, too.

We also recommend that you create a backup of your site before starting to troubleshoot.

For the first method, we’ll look at something that takes about 30 seconds.

1. Reconfigure Your WordPress Permalinks

WordPress provides you with multiple choices of permalink structures. ‘Permalink’ stands for permanent link. It’s the URL your website visitors use to access your pages and posts.

In some cases, WordPress might run into errors when generating permalinks, leading to 404 errors. To solve this problem, you’ll need to temporarily reset your site’s permalink structure. This will only apply if you’re using any other permalink structure than the default Plain.

To reset your permalink structure, access your WordPress admin area and go to the Settings > Permalinks page. Memorize or note down your current settings here, then select the Plain option under Common Settings:

Configuring permalink settings in WordPress.

Once you save your changes, the page will reload. At this point, simply re-select your old permalink structure and save your changes again.

Although the permalink structure has only been reset once, this can often be enough to make the 404 error go away. If it doesn’t, you’ll need to dig deeper into WordPress.

2. Restore Your Default .htaccess File

Your .htaccess file includes instructions for how WordPress should interact with your server. Among those instructions, there are rules for how to generate your site’s permalinks.

If resetting your website’s permalink structure from the dashboard didn’t solve the problem, the next step is to restore the .htaccess file to its original state.

In many cases, your WordPress plugins or hosting provider make changes to your .htaccess file — some of which might cause errors on your website. Returning it to its default state gives you a clean slate to work from.

To locate your .htaccess file, connect to your website via your FTP client and open your root folder (usually called public_html). The .htaccess file should be here. Right-click on it and select the View/Edit option:

Editing your htacess file via FTP.

This will open the file using your default text editor. Delete the file’s contents and replace it with the following code:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

This is essentially the contents of a default .htaccess WordPress file. Once you paste this code into your site’s .htaccess file, save your changes and close it.

Your FTP client should ask you if you want to update the file on your server — you do want to! Finally, try to access your website again to see if the 404 error persists.

If the error is gone, you can return to the Settings > Permalinks page in your WordPress dashboard to change your permalink structure back to its previous format. At this point, things should be right again. If not, you’ll need to move onto the next method.

3. Disable All Your Themes and Plugins

In some cases, compatibility issues between plugins, themes, and WordPress itself can cause 404 errors on your website.

So, if you’ve tried both of the previous methods without success, the next step is to deactivate all your plugins and themes to see if you are having a compatibility problem.

To disable your plugins and themes from the dashboard, simply head to the relevant screen within the WordPress admin area (Plugins > Installed Plugins or Appearance > Themes), select the plugins or themes you want to disable, then choose the Deactivate option under the Bulk actions drop-down menu, and click the Apply button:

Disabling plugins through the WordPress dashboard.

This is the fastest way to disable all the plugins on your website. Doing so will probably impact your site’s functionality, but it’s necessary to rule out each plugin as the cause of the 404 error. If you don’t want to perform this action on your live site, we recommend that you create a staging site.

If the error persists after disabling every plugin, you’ll also need to disable your active themes. 

And, if the error still doesn’t disappear, reactivate all the plugins and themes and do the following:

  1. Deactivate the plugins one by one.
  2. After disabling a plugin, test if the WordPress 404 error persists.
  3. If the error persists, re-activate the plugin and repeat the process with the next one.

This should enable you to isolate which plugin is causing compatibility issues on your website. 

If the 404 error prevents you from accessing your dashboard, you can also disable plugins and themes on your site via FTP. To do so, connect to your website through your FTP client, navigate to your root folder, and access the wp-content directory. Here, you’ll see several folders, including two called plugins and themes:

Accesing your WordPress plugin and theme folders via FTP.

Each of those directories includes subfolders for all the plugins and themes installed on your website.

To disable plugins en masse, you can right-click the plugins folder and rename it to anything else, e.g. plugins.old. Then, create a new plugins folder, which should be empty:

Renaming your plugins directory via FTP.

Now try to access your website again to check if the 404 error still pops up. If it’s gone, then you can delete the empty folder and rename the other one back to plugins

Your next move is to rule out individual plugins. To do so, open the plugins directory and follow these instructions:

  1. Rename a plugin’s folder.
  2. Check if the 404 error persists on your website.
  3. If yes, rename the folder back to its original name and repeat the process with the next plugin.

If the error disappears at any point, you can assume that plugin is the culprit. At this point, you’ll want to either contact the developer for a fix, look for a suitable alternative, or uninstall the plugin.

This process works much the same with themes. If you rename your active theme’s folder, WordPress will automatically use the default theme instead. After renaming the folder, test your website and if the error is gone, your former theme was the root cause.

Conclusion

WordPress posts returning 404 error is a troublesome issue. If visitors can’t find what they’re looking for on your website, they might give up and look elsewhere. This means leaving 404 errors unchecked may have a significant impact on your bounce and conversion rates.

If you’re running into 404 errors on your WordPress site that aren’t caused by wrong URLs or caching issues, here’s how to fix them:

  1. Reconfigure your WordPress permalinks.
  2. Restore your .htaccess file.
  3. Disable all your themes and plugins.

Do you have any additional questions about how to solve WordPress 404 errors? Let us know in the comments section below!

FREE COURSE

Buckle Up!
5 Steps To Speed Up
Your WordPress Site

Make your site run 30-40%
faster with a few simple techniques

Join Free Course
rocket

Source link

Leave a Reply

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

seven + 19 =

Previous post Viral Mag – WordPress theme
Next post MailerLite vs ConvertKit: A Hands-On Comparison (2021)