Custom Post Type 404 error

How to Fix Custom Post Type redirecting to 404 Page

While working on a custom post type, sometimes the pages shows 404 page.

Below are my solutions everytime I experience this error. Here are 3 things that you should try.

  1. Update the Permalink. To do this, go to Settings > Permalinks and hit Save changes.
  2. Create a Page Tempalte. Double check if you already have a single-{YourCustomPostType}.php that will serve as a page for your new custom post type. It may show a 404 page if it doesn’t exist.
  3. Use This code. Paste the code below right after you register a custom post type.