I decided to delete a custom post type and change them to pages instead. The pages display properly but anything in the directory that the custom post type used is returning a 404 even though the pages display normally.

Here is an example

Every page in the /accidents/ subdirectory is returning a 404 even though the page is displaying the proper content.

I deleted all of the posts with that posttype out of the database but I think I must be missing something.

Any ideas?

  • You should explain your question in the body of the post, not the title :-) Commented Jun 18, 2014 at 6:01

2 Answers 2


This issue can be a little difficult to triage. I would start by checking your permalinks structure. When you save it the new code will be written to the .htaccess file.

WordPress will behave like this when you request a URL that isn't there. It will give a 404 but it will search through the database for a similar slug and show that page.

If you have a page at /content/my-post-slug and someone punches in /my-post-slug it will, usually, try to 302 Redirect to that post. I have run into cases where this 404 behavior happens, though. Something about the .htaccess mod_rewrite config causes WordPress not to redirect correctly.

  • 1
    You might also verify all the category slug names for both your posts and your pages.
    – zipzit
    Commented Jun 16, 2014 at 20:31
  • So, I changed my permalinks which had no effect. I've tried changing the parent page name to accident instead of accidents and that fixes it but if I change it back to accidents it breaks again. It seems like it's looking for a post that no longer exists and then is 404ing but returning the page that now exists at that url or something to that effect. I've tried completely deleting my .htaccess as well which makes no difference. This is what leaves me to believe it has to do with remnant data from the custom post type "accidents" that I deleted but I'm not really sure what. Commented Jun 16, 2014 at 21:14
  • It certainly could. Unfortunately the magic that happens under the hood for finding old slugs is difficult to deal with. It also leaves a trail of records in your database. You can forcibly disable it by adding this to your functions.php: remove_action( 'template_redirect', 'wp_old_slug_redirect' ); Commented Jun 17, 2014 at 1:03
  • That didn't work. I finally got it to work by flushing my rewrite rules with <?php flush_rewrite_rules( false ); ?> I thought I had tried that before but I realized I had the code wrong. Commented Jun 18, 2014 at 0:09

I finally got it to work by flushing my rewrite rules with <?php flush_rewrite_rules( false ); ?> in my functions.php. I added it, refreshed the page and then removed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.