Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
You should explain your question in the body of the post, not the title :-) –  Pieter Goosen Jun 18 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.

share|improve this answer
1  
You might also verify all the category slug names for both your posts and your pages. –  zipzit Jun 16 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. –  spindecision Jun 16 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' ); –  infamouse Jun 17 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. –  spindecision Jun 18 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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