How to fix WordPress posts returning 404 error

Introduction

You publish a new blog post, click “View Post”… and get a 404 Page Not Found error. It’s one of the most common—and annoying—WordPress issues.

The good news? Your content isn’t gone. The 404 error just means WordPress can’t find the post at the URL it’s expecting.

This usually happens due to a broken permalink structure, corrupted .htaccess file, or plugin conflict.

In this guide, you’ll learn step-by-step how to fix WordPress posts returning 404 errors, whether you’re a beginner or a developer.

Understanding the WordPress 404 Error

The 404 error means the requested URL can’t be found on your server.

🔍 How WordPress Handles URLs

WordPress uses a system called “rewrite rules” to translate pretty permalinks (like /my-blog-post/) into internal queries (?p=123).

These rewrite rules are stored in your .htaccess file (for Apache) or server config (for Nginx).

When something breaks in that system—like missing rewrite rules or a bad redirect—you’ll see a 404 even though the post exists.

⚠️ Post 404 vs. Site 404

  • Post 404 – Only single post pages show 404 (home and pages still work).
  • Full Site 404 – Every page returns 404 (usually a server issue).
This guide focuses on post-only 404 errors, which are most common.

Common Causes of WordPress 404 Errors on Posts

Let’s quickly look at why this happens:

Cause Description
Broken Permalink Structure The URL rewrite rules are corrupted or not saved properly.
.htaccess File Missing/Corrupted Without the correct rewrite rules, WordPress can’t handle permalinks.
Plugin or Theme Conflict A plugin (like SEO or caching) can override or break rewrite settings.
Recent Site Migration Moving domains or folders can break URLs and database references.
Cached URLs or CDN Issues Your CDN or cache might be serving old or invalid URLs.

How to Diagnose the Problem

Before fixing, let’s confirm what’s broken.

01. Check If It’s Only Posts

  • Visit your homepage — does it load fine?
  • Open any post — does it show 404?
If yes, your database is fine — it’s a permalink issue, not missing content.

02. Check Permalink Settings

  • Go to Settings → Permalinks.
Now, Take note which structure is selected (like “Post name”). Don’t save yet.

03. Inspect the .htaccess File

If you’re on an Apache server, your .htaccess file should be in the WordPress root folder. Open it and see if it contains the default WordPress rewrite rules (we’ll show them later).

04. Check Site Health

  • Go to Tools → Site Health → Info → Server.
  • Ensure that mod_rewrite is enabled (for Apache) or that your Nginx config allows permalinks.

Fix 01: Reset Your Permalink Settings

This is the easiest and most effective fix.

🧠 Step-by-Step

  • Log into your WordPress dashboard.
  • Go to Settings → Permalinks.
  • Note your current structure (e.g., /post-name/).
  • Switch to Plain and click Save Changes.
  • Switch back to your original structure and click Save Changes again.

This forces WordPress to flush and rebuild its rewrite rules.

✅ Result

Your posts should now load normally without returning 404 errors.

Fix 02. Manually Update or Recreate the .htaccess File

If resetting permalinks doesn’t help, your .htaccess file might be missing or corrupted.

⚙️ Default .htaccess for WordPress

Open your website root folder (via FTP or File Manager) and check for .htaccess. If it’s missing or empty, create a new one with this 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

				
			

Save the file, then go back to your dashboard → Settings → Permalinks → Save Changes again to rebuild.

🧰 Permission Check

Ensure the .htaccess file has 644 permissions (readable by WordPress).

Fix 03. Check for Plugin or Theme Conflicts

Sometimes plugins (like SEO or caching tools) modify URLs or intercept rewrite rules.

🧩 Troubleshooting Steps

  1. Deactivate all plugins temporarily.
  2. Check if posts load properly.
    • If yes → one of your plugins is the culprit.
  3. Reactivate plugins one by one and test.

⚙️ Common Culprits

  • Yoast SEO or Rank Math (if custom canonical URLs are misconfigured).
  • WP Rocket, LiteSpeed Cache, or W3 Total Cache (if caching outdated URLs).
  • Redirection or 301 redirect plugins with incorrect rules.

🧠 Theme Conflicts

  • Switch to a default theme like Twenty Twenty-Five.
  • If posts work fine, your theme’s functions.php may have conflicting rewrite or redirect logic.

Fix 04. Flush Rewrite Rules via Code

If you can’t access the dashboard (e.g., admin 404s too), you can flush rewrite rules manually using code.

🧰 Steps

  • Connect to your site via FTP or File Manager.
  • Open your theme’s functions.php file.
  • Add this code at the bottom:
				
					add_action('init', function() {
    flush_rewrite_rules();
});

				
			
  • Visit your homepage once (this triggers the code).
  • Then remove the line to prevent unnecessary rule flushing.

This forces WordPress to rebuild its internal rewrite table.

Fix 05. Clear Cache and CDN

Sometimes your pages work fine on the server but you’re seeing cached 404s.

⚡ Steps

  • Clear your WordPress cache using your caching plugin:
    • WP Rocket → Settings → Clear Cache
    • LiteSpeed Cache → Toolbox → Purge All
    • W3 Total Cache → Performance → Purge All Caches
  • If using a CDN (e.g., Cloudflare, BunnyCDN, KeyCDN):
    • Log in → Cache → Purge Everything.
  • Hard refresh your browser (Ctrl + Shift + R).

If cached 404 pages were being served, this will fix it immediately.

Fix 06. Check URL Redirection or SSL Migration

If you recently migrated from HTTP to HTTPS or changed your domain, your URLs might be inconsistent.

🧠 Step-by-Step

  1. Install Better Search Replace.
  2. Go to Tools → Better Search Replace.
  3. Search for: http://your-old-domain.com
  4.  Replace with: https://your-new-domain.com
  5. Run the replacement on all tables.

💡 Use Redirection Plugin

Install Redirection to manage 301 redirects and monitor broken links.

  • Go to Tools → Redirection → Add new redirect.
  • Enter old URL and new URL.

Fix 07. Inspect Server or Hosting Configuration

If all the above fails, the issue might be with your hosting environment.

🔧 For Apache Servers

Check that mod_rewrite is enabled. You can ask your host or run this test via PHP:

				
					<?php phpinfo(); ?>
				
			

Search for “mod_rewrite” – if it’s missing, ask your host to enable it.

⚙️ For Nginx Servers

Make sure your server block includes this configuration:

				
					location / {
    try_files $uri $uri/ /index.php?$args;
}

				
			

If you’re not comfortable editing this, ask your hosting support to verify your Nginx rewrite rules.

Bonus Tip: Use a Custom 404 Page for Better UX

Even when you fix 404s, having a custom error page improves user experience and SEO.

💡 Why You Need It

A plain “404 Page Not Found” can frustrate users. A custom one helps redirect them to working content.

🧰 Best Plugins for Custom 404 Pages

🪄 What to Include

  • Friendly message (“Oops! That page doesn’t exist.”)
  • Search bar
  • Popular post links
  • Button to return to the homepage

Preventing Future 404 Errors in WordPress

Once fixed, here’s how to keep 404 errors from returning:

✨ 1. Keep Permalinks Stable

Avoid frequently changing your permalink structure.

✨ 2. Always Backup Before Major Changes

Use UpdraftPlus or All-in-One WP Migration before editing .htaccess or functions.php.

✨ 3. Monitor Broken Links

Use tools like:
  • RankMath 404 Monitor
  • Broken Link Checker
  • Ahrefs Webmaster Tools

✨ 4. Test After Plugin Updates

Some plugins modify URLs during updates—check your posts afterward.

✨ 5. Use Redirects After Content Deletion

If you remove a post, redirect its URL using the Redirection plugin to avoid SEO loss.

Conclusion

WordPress posts returning 404 errors are frustrating—but they rarely mean your content is gone.

Most of the time, it’s just a permalink or .htaccess issue that can be fixed in minutes.

✨ To recap:

  • Reset your permalinks.
  • Recreate the default .htaccess file.
  • Check for plugin/theme conflicts.
  • Flush rewrite rules or clear your cache.
  • Confirm your hosting supports mod_rewrite.

Once fixed, your posts will load normally again – and your SEO rankings will thank you!

FAQs

✅ Final Tip

After applying these fixes, run your site through Google Search Console → Crawl Errors to identify any remaining 404s and ensure everything’s back on track.

Share it :

Picture of Kawshar Ahmed
Kawshar Ahmed
I am Kawshar, a professional WordPress Developer & Elementor Expert. I have been working with WordPress for the last 5 years. I am based in Dhaka. I am proficient in JavaScript & PHP, additionally I can manage Web Server and Email Server. I specilize in creating stunning, responsive and nice looking website using WordPress.
Picture of Kawshar Ahmed
Kawshar Ahmed
I am Kawshar, a professional WordPress Developer & Elementor Expert. I have been working with WordPress for the last 5 years. I am based in Dhaka. I am proficient in JavaScript & PHP, additionally I can manage Web Server and Email Server. I specilize in creating stunning, responsive and nice looking website using WordPress.

Leave a Reply

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

Table of Contents