How to Fix WordPress Custom Post Type Permalink 404 Error

For almost two hours I was pulling whatever hair is left out of my head because I was registering a custom post type, and its posts, archives and categories would generate 404 errors using the %category%/ %postname% permalink structure. I knew that my post type was fine so there was just something that kept messing up my work. In my case it was another plugin that was causing the errors but I figured I should put a semi-compete troubleshooting list together so you can fix your Custom Post Type permalink errors.

First thing first, let’s register a Custom Post Type called book and give it a pretty slug “book”.


This means that when you add a post under this type, your permalinks would be:

and the archive for this post type would be:

What happens here is that WordPress tries to rewrite your slug to “book” and this is where the problems begin.

Things to check:

  1. Before you do anything else, first go to setting/permalinks and re-save the permalink structure. This will hard flush the rewrite rules inside your htacess and most of the time will fix your problem. If you’ve re-saved your permalink structure and the problem still exists go the next step. In your functions.php right after:register_post_type( ‘book’, $args ); // your slug and arguments will be different obviouslyAdd


    Save, upload the file, and test again. If the permalink starts working, it means that your post type is registered correctly and something else is messing it up. Go ahead and remove the line you just added as although it seems that it fixed the problem, it’s just a band aid and not a good one either. What this function does is that it constantly flushes the rewrite rule with every request so you definitely don’t want it in there. Now that we know the post type registration was OK, Proceed to the next step.

  2. Make sure you don’t have a page, category, tag, post, tag base, or category base with the same slug. This means if you have a page called Book with a slug “book”, WordPress will go crazy and rightfully so. The fastest way to find out is to dump your database and open it with a text editor like Notepad++ and do a search for book. If you see a duplicate somewhere, rename either your custom post type slug or fix the other page. If this doesn’t fix the problem, proceed to the next step.
  3. This is where the real troubleshooting begins. If you have a custom theme, switch to one of the default themes that ship with WordPress like the Twenty Eleven or Twenty Twelve. Re-save the permalinks structure again and test. If this doesn’t fix it, proceed to the next step.
  4. Disable all the plugins and resave the permalinks again. This will definitely fix your problem so test and see. Now that we know that your theme is fine, your custom post type is fine, and permalinks have been flushed, there is only one possibility. It’s one of your plugins that’s calling the flush function and is doing wrong. Start activating your plugins one at a time, resaving the permalinks after each activation, and test your custom post type. This will pin point your problem source and then you either have the option to ditch the faulty plugin, report it to its developer, or try to fix it yourself.

Hope this comes handy the next time you’re pulling your hair out of your skull. If you have questions or comments, leave them below.

47 Responses to How to Fix WordPress Custom Post Type Permalink 404 Error

  1. Avatar for Douglas Douglas says:

    Hi! First of all, thank you for this post!
    So, my problem is the error 404 in term children: example:, as well terms in type ‘book’, for example.

    How can I fixed this error?


  2. Avatar for Dave Dave says:

    I love it when a 5-year old post saves my ass. Thanks!

  3. Avatar for Mark Mark says:

    Thank you for this! I forgot to flush my permalink settings (that is, save them). This article reminded me to do this. 😉

  4. Avatar for edouard edouard says:

    Hello, am having an issue with the page displaying.

    register_post_type( ‘books’,$arg);

    am using a single.books.php page to read the content from the register post, in my sample book.

    when am viewing the page, for exemple ../books/my-book/ its works.

    However, when am going on : /books/ am having a 404 error. i think i must use a slug/taxomie-NAME.php, but don’t know which one. can you help ?

  5. Avatar for Ashwin Ashwin says:

    I was using CPT UI plugin and geting the same error. Nothing worked until I found an option in the Edit post type called Has Archive which was selected false by default. Made it True and bingo 🙂

  6. Avatar for Farrukh Farrukh says:

    Thanks a lot for this post.

  7. Avatar for Clyde Thomas Clyde Thomas says:

    Settings/Permalink -> Save helped me! Thanks!

  8. Avatar for Stéphane Stéphane says:

    Thanks a lot ! I would have looked for hours without reading your article. Have a great day!

  9. Avatar for Joshua Davis Joshua Davis says:

    Settings/Permalink -> Save helped me! Thanks!

  10. Avatar for David Richied David Richied says:

    Permalinks save the day, again. Thanks!

  11. Avatar for Michael Michael says:

    Thanks. Resaving permalink fixed it.

  12. Avatar for Jesualdo Jesualdo says:


    This have fixed my problems 🙂 TY!!!

  13. Avatar for subash subash says:

    good post

  14. Avatar for Pablo Pacheco Pablo Pacheco says:

    Just to share. In my case it was the parameter

    ‘query_var’ => false

    It should be true

  15. Avatar for Roy Huggins Roy Huggins says:

    This article did the trick for me. Thanks!

  16. Avatar for Andru Andru says:

    Thank very much!

  17. Avatar for Fabrice Court Fabrice Court says:

    I’ve been searching for 2 hours
    I’ve find you’re precious article and have a solution
    You make my day !!

    Many Thanks

  18. Avatar for Lara Lara says:

    Mwah!! You are an absolute star.

    Had issues for hours and hours and was so stressed then found your blog, re saved my perms links and I’m a happy little Vegemite once again yaye!

    Thank you thank you thank you!

  19. Avatar for Guy Labbé Guy Labbé says:

    just to share… this didn’t work for me, finally, my register_post_type arguments array had “has_archive” => false which caused the permalink to fail (strange!)

  20. Avatar for Milena Milena says:

    Hi Chris ,

    Thanks for this tutorial. I have another issue though and I spent hours researching with no success. Perhaps you can help?
    My custom posts have normal taxonomies assigned to them (just the regular categories and tags) but when I press on one – I get a 404 page. (Only when I press on blog categories & tags I get to see posts) How do I get the archive / category page to display custom posts too?

    Thank you!

  21. Avatar for Csaba Csaba says:

    One remark: I could not find “register_post_type( ‘book’, $args ); // your slug and arguments will be different obviously” in the functions.php file under wp-includes

  22. Avatar for Csaba Csaba says:


    It was very interesting what you have suggested here. Unfortunately, in my case it did not help. I went along all the way through the steps you have detailed but could not fix the problem.

    I have a Hungarian website and if I change the Permalink settings form /%postname%/ to “Day and name” or “Month and name” for example, they are working fine. But “Post name” is not working.

    I find it very strange, could you tell me why isn’t it working?

  23. Avatar for Todd Todd says:

    Just wanted to say thank you resetting the permalinks did it for me and this article is great for just troubleshooting errors in general thanks for the advice and saving my night! Gave it a facebook share as well.

  24. Avatar for trashy trashy says:

    THANKS, simply flushing the permalink settings worked for me.

  25. Avatar for Chris Burbridge Chris Burbridge says:

    Thank you very much, indeed.

    flush_rewrite_rules() worked.

    However, please note in the docs that it says this is an expensive operation, so the proper place to put it is in the activation or deactivation hook for the plugin —

  26. Avatar for Jonathan Jonathan says:

    …and remember the ‘has_archive’ => true argument in register_post…

    • Avatar for Colin Colin says:

      you are a gosh darn life saver! Looked all over this internet and this was the issue all along! Thanks everyone!! you are all great!

  27. Avatar for Charles K Howard Charles K Howard says:

    “The flush_rewrite_rules();” snippet resolved this issue for me.

    Thank you so much!

  28. Avatar for Arles Arles says:

    Thanks man! Re-saving the permalink structure did it for me 😀

  29. Avatar for Andrés Andrés says:

    Thank you! You’ve been really helpful, I was about to rewrite my custom post types code to try and fix it.

  30. Avatar for MPossDesign MPossDesign says:

    Thank you for posting this. Just spent close to 3 hours trying to work out why my custom post type was getting a 404 error.

  31. Avatar for Gokula krishnan Gokula krishnan says:

    Hi Chris, Great!!! its worked out for me. Very useful and valid post.

  32. Avatar for frank frank says:

    Hi Chris, thanks a lot. I have searching the failure for hours. Because of your article I know now:My Theme doesn´t work right.
    Can you give me any hints about what can be wrong in my theme?

  33. Avatar for Heeren Heeren says:


    i was using custom permalinks %postname%.html and somhing was causing a redirect when vi visit post page it was redirecting to Postname.html/ .

    flush_rewrite_rules(); in function.php fixed the issue .. Thanks a lot.

    • Avatar for Chris Sorbi (Admin) Chris Sorbi (Admin) says:

      You can’t use .html in the permalink structure. Remove the .html and you should be fine. It should only read %postname%

  34. Avatar for Davide De Maestri Davide De Maestri says:

    Hi there, I’ve got the same problem. Plugin generate the right url but I only see 404 error page. Just tried flushing etc.

  35. Avatar for ucarman ucarman says:

    have done that. have also tried flush rewrite rules in default theme.have checked wp-posts tables in database to make sure there were no posts or pages with same name as custom post type. could it be a sever error?

  36. Avatar for ucarman ucarman says:

    yes map-cap requirements are met. i have two other wordpress installations that are using all the same plugins. both of these work perfectly. i have run out of ideas was hoping i could find some solution.

    • Avatar for Chris Sorbi (Admin) Chris Sorbi (Admin) says:

      Have you tried switching your theme for the default theme? Do that and re-save the permalinks and see what happens.

  37. Avatar for ucarman ucarman says:

    placed flush_rewrite_rules(); in functions.php of my theme still have error.
    i did find that flush_rewrite_rules(); is included in the custom post type UI plugins php file.

  38. Avatar for ucarman ucarman says:

    i have been trying to sort this out for about a week.
    i am using custom post type UI plugin to register post types. Add Custom Post Types Archive to
    Nav Menus plugin also map-cap plugin.
    whenever i try to preview changes after post is published i get a page not found error.
    I cannot view or edit custom post types with these plugins deactivated however i deactivated all others
    I have note tried flush_rewrite_rules(); because i am unsure of where to place the code because i am using the plugin to register custom post types.
    any ideas would be helpful. i tried everything else in your list with the above exceptions.

    • Avatar for Chris Sorbi (Admin) Chris Sorbi (Admin) says:

      One of your plugins is causing the problem. put the flush_rewrite_rules(); in the function.php of your them and try again.

  39. Avatar for Jason Jason says:

    I just wanted to add this in the comments. I just spend 4 hours last night trying to get this permalink issue fixed. I tried everything I could find on the web. I am using Centos 6 on my vps. I found another area in the httpd.conf that reads:
    #AllowOverride controls what directives may be placed in .htaccess files.
    # It can be “All”, “None”, or any combination of the keywords:
    # Options FileInfo AuthConfig Limit
    AllowOverride none

    Here is a quick article I wrote up so other people trying to fix would not waste so much time!

Leave a Reply

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