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?

  • 2
    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
    Commented Sep 16, 2015 at 13:09
  • Thanks. That fixed the link to the post itself, but not the archive-top_charts.php page. Strange! Commented Sep 16, 2015 at 13:15
  • Just adding part of it in answer that may help other users and try to look for archive as well.
    – jas
    Commented Sep 16, 2015 at 13:18
  • found the simple answer to this bug on another stack post: Custom Post Type Permalink Page Not Found
    – dnll
    Commented Jul 31, 2017 at 11:21

5 Answers 5


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.

  • 1
    great you found 'has_archive' :)
    – jas
    Commented Sep 16, 2015 at 13:33
  • 1
    why does this still work? and why isn't this a wordpress bug?
    – Cerveser
    Commented Sep 4, 2020 at 18:09

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

  • 3
    I believe I also needed has_archive, but good to know you can force a flush through the menu. Commented Jan 9, 2017 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? Commented Jun 2, 2017 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.


I just added this line for rewrite rules this was the reason for me. after comment or removed it solved but you can make it true also.

flush_rewrite_rules( true );

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

  • I follow the way of @David Salcer, created a htaccess file and then it works.
    – ca hoang
    Commented Jun 2, 2023 at 3:57

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