I've created two new Custom Post types using code that I've used successfully on other projects without issue. The first is called top_charts, the other case_studies, and both appear correctly in the admin menu and I can create new posts.

Unfortunately the new posts don't appear. I just get a 404.php response.

I've created an archive-top_charts.php to see if I can get anything to appear, but I see a 404.php "page not found" reply.

I originally named the custom posts top-charts and case-studies, but I thought the hyphen might have been the problem, and so renamed them to use an underscore instead. It hasn't helped.

I've tried re-saving my Permalinks, but nothing has changed. My .htaccess page looks like what you'd expect, too (and other pages works fine). What else can I check?

  • 1
    have you used flush_rewrite_rules( false ); in register post type? for more details follow this link nooshu.com/page-not-found-with-custom-post-types – jas Sep 16 '15 at 13:09
  • Thanks. That fixed the link to the post itself, but not the archive-top_charts.php page. Strange! – Django Reinhardt Sep 16 '15 at 13:15
  • Just adding part of it in answer that may help other users and try to look for archive as well. – jas Sep 16 '15 at 13:18
  • found the simple answer to this bug on another stack post: Custom Post Type Permalink Page Not Found – dnll Jul 31 '17 at 11:21

For fixing custom post not found please use below code in your functions.php:

flush_rewrite_rules( false );

You should only do this as a temporary measure otherwise it will run on every page load.

For more details please follow this link

As for the archive-top_charts.php not appearing, make sure you have 'has_archive' => true when you're registering your post type.

| improve this answer | |
  • great you found 'has_archive' :) – jas Sep 16 '15 at 13:33

You don't have to edit your php code!

While you can do this in the function that registers your custom post type, like the other answers, you can also do this in the settings menu, thus avoiding touching your php code:

To flush WordPress rewrite rules or permalinks (usually needs to be done manually for new custom post types) from the Dashboard:

  1. In the main menu find "Settings > Permalinks".
  2. Scroll down if needed and click "Save Changes".
  3. Rewrite rules and permalinks are flushed.

It's that simple!

image of saving permalinks page reference

| improve this answer | |
  • 2
    I believe I also needed has_archive, but good to know you can force a flush through the menu. – Django Reinhardt Jan 9 '17 at 11:44
  • 1
    Is there any way to save changes to (update) permalinks automatically rather than going to Settings > Permalinks every time a CPT category/term is added? Like how will non-admin be able to do this if they don't have access to settings? Can a hook be called when adding a new category to flush permalinks automatically? – Ryan Coolwebs Jun 2 '17 at 2:08

I realize that this is late in the game (and may not be the related problem), but I wanted to point out to others a possible issue.

In my case, I had set my taxonomy rewrite to tools and the content type rewrite to the same thing. Therefore, it would never work properly as it was a conflict. Unfortunately, there is no detection for such a thing so I figured I would just point it out to others.

| improve this answer | |

In my case it was missing rights in my development folder so .htaccess file could not have been created ad/or modified.

So manual flushing or Saving changes in WP Permalinks was not helping.

Solution was to create .htaccess file by myself

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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