How to Fix WordPress Custom Post Type Returning 404 Error

How to Fix WordPress Custom Post Type Returning 404 Error

WordPress came with the ability to allow developers to add Custom Post Type to extend the functionality of WordPress. But if you have worked with custom post type before, you have probably encountered the infamous 404 not found error when trying to access a custom post type. In this article, we are going to show you two easy methods to fix this issue.

Why WordPress is Returning 404 for Custom Post Type?

404 error means WordPress is unable to find the custom post type that you are trying to access, for a more detailed explanation see List of Common HTTP Status and Error Codes. This error is due to a conflict between your WordPress permalink settings and rewrite logic in register_post_type() function.

How to Fix Custom Post Type 404 Error Issue in WordPress

You will most likely get a 404 error for the newly created custom post type. This error can be fixed by flushing the permalink rewrite rules from WordPress dashboard.

  1. Login to dashboard, the default WordPress dashboard url is yourdomain.com/wp-login.php
  2. Go to SettingsPermalinks
  3. Click on Save button to clear the rewrite rules

Check the custom post type page you were having issue with before, 404 error should be fixed now. Flushing the rewrite rules is the quickest way to fix 404 error with custom post type, but if this doesn’t work, then you will have to check for duplicate slug issue.

How to Fix 404 Error by Resolving Slug Conflict

One another common cause for 404 error is duplicate post slug. For example, if you named your custom post type “editor” and you also have a page with the same name, this will create a conflict and cause 404 error. The solution for this issue is very easy, either change the name of the custom post type or rename the page to something else.

If you are still having 404 issue, try switching to the default theme and see if you are stilling seeing this error. If this error goes away after you switched, the issue is most likely caused by the custom theme you are using, contact the theme’s author for help.

You May Also Like