Presenting our step-by-step guide for beginners that helps you how to fix WordPress custom post type 404 error easily. Stick here till the end!
WordPress is the most used CMS nowadays because of its ease of use. But sometimes a slight tweak could ruin your website or make it inaccessible for your site visitors because of 404 errors.
If it is also happening with you, we’ve got you covered as we’ve mentioned 5 ways on how to fix WordPress custom post type 404 error.
Let’s get started by understanding about custom post types in a brief.
What do you mean by Custom Post Types?
WordPress is not just a blogging platform with post and pages as the main content types. Rather, it’s your choice what type of content you would like to present in front of your audience. And, the type of content you’ll use other than the main content type (i.e., Posts and Pages) are known as custom post types. Because you’re customizing your preferences.
For example-
If you want to run a product review website, then you would probably like to create Review Posts on your site. In that case, your Review Post Type can have different custom fields as well as custom categories that you think fit for your posts.
Similarly, you can create a testimonial content type, Portfolio, Product Post type, Courses, etc.
By default, WordPress comes with five post types such as Posts, Pages, Attachments, Revisions, Nav Menu, Custom CSS, Changesets, User Data RequestHow to create a custom post type?
For all noncoders, just to eliminate the lengthy and complex process of coding, there is no better option than using WordPress Plugins.
And, your solution to creating custom post types lies in WordPress Plugins.
One such plugin is Custom Post Type UI that provides you with an easy to use interface to register and manage custom post types and taxonomies for your WordPress website.
How to fix WordPress Custom Post Type 404 error
Confronting issues with the custom post type error in your site on WordPress?
I can relate your situation how it hurts when the server shows the message ‘Error! 404 not found’. Ah! Quite Frustrating!
Whenever there is a problem, a solution is also there. Here we are going to tell you 5 ways on how to fix WordPress custom post type 404 error easily in your site.
Learn To Fix Common WordPress Errors1. Permalink Settings
A permalink refers to the permanent URL that shows the URL address to your posts, categories, archive, and other pages on your WordPress site. Each post, page, category, archive has a unique link.
- Login to your admin dashboard and click on Settings Tab> Permalinks.
Select the Plain radio option and save the changes. - Go to your custom post pages now. Check whether they return 404 error pages or not.
- If yes, then go back to the Permalinks option under the settings tab and set the permalinks back to default.
If this process is not working, check whether your .htaccess file is updated or not.
2. Check Title and Slug
Maybe your Title and Slug are conflicting because of the similar names.
It might be possible that your custom post type page has the same title or slug as your actual post type. For example, you have a custom post type ‘product’. On the other hand, you have also created a main page named ‘Product”. This will create a conflict between both with the title/slug ‘product’ resulting in 404 errors on your single post type posts.
Just change the Title/Slug either of your page or custom post type in order to fix 404 errors.
3. Switch to the default WordPress Theme
Try switching to some default WordPress theme from your custom WordPress theme. Some common examples of default WordPress themes are Twenty Fifteen, Twenty Sixteen or Twenty Seventeen
Now, try to save again and test all permalinks structure. Hope this will fix your issues.
4. Update Your WordPress Plugins
You can move on with this option if none of the above-listed ways are working for you.
- First of all, deactivate all the plugins. Now, try to save permalinks again.
- After that, activate again your plugins one by one. but don’t forget to resave the permalinks after each plugin activation.
- Test again all your custom post types.
5. AutoFlush Rewrite Rules
If you are a developer, you can opt for this method.
Whenever a new custom post type is created and registered, you should not forget to “flush” your rewrite rules in the WordPress site.
How to flush rewrite rules?
- Click on Settings tab > Permalinks
- Click the save option.
You can consider autoflush rewrite rules, in case, you’re working on a custom theme or plugin. Here is an example of the code that you can use to rewrite rules:
</p> <p>// Code for themes<br /> add_action( 'after_switch_theme', 'flush_rewrite_rules' );</p> <p>// Code for plugins<br /> register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );<br /> register_activation_hook( __FILE__, 'myplugin_flush_rewrites' );<br /> function myplugin_flush_rewrites() {<br /> // call your CPT registration function here (it should also be hooked into 'init')<br /> myplugin_custom_post_types_registration();<br /> flush_rewrite_rules();<br /> }</p> <p>
Hope this trick will fix 404 errors in your WordPress site.
Final Thoughts on Custom Post Type 404 Error
Fixing 404 errors is important to stick site visitors on your site as well as to improve search engine ranking. If you are still not able to fix your 404 error, do contact us. We’ll try fixing your problem.
Have another issue? Leave a comment below. We’ll find a solution for you.