I've created custom post types in a theme before (actually on the exact theme I'm having trouble with now), and everything has gone relatively seamlessly. However, now I've run into an issue where a post type that I'm trying to create, with archive and content php files, is not working. More specifically, the slug is not working.

function sop_posttype() {
  register_post_type( 'sop',
      'labels' => array(
        'name' => __( 'SOPs' ),
        'singular_name' => __( 'SOP' )
      'slug' => 'sop',
      'menu_icon' => 'dashicons-editor-help',
      'public' => true,
      'has_archive' => true,
      'supports' => [ 'title', 'editor', 'thumbnail' ]
add_action( 'init', 'sop_posttype' );

Above is my registration for the post type. It is almost exactly the same as my previous post type, only with a different name.

My archive file is called archive-sop.php, and my content file is called content-sop.php.

I can't seem to see anything missing in my registration code, and the other post types are working correctly, but for some reason I'm still getting a 404 when I try to visit the archive page (http://url.com/sop/), even though I've added a test post.

  • 2
    Have you flushed your rewrites? Just go to "Settings" > "Premalinks" and hit Save.
    – JHoffmann
    Mar 1, 2017 at 21:09
  • Maybe check out the rewrite parameter of register_post_type()
    – Howdy_McGee
    Mar 1, 2017 at 21:28

2 Answers 2


You have to flush the rewrite rules of WordPress. You can do it either by going to Permalink Settings and click save or by using flush_rewrite_rules

That's happens because WordPress doesn't know the URL-structure of your new custom post type. Read more here: Custom Post Type and Permalink

  • Oh, duh. I remember having to do that previously. Thank you. Mar 4, 2017 at 14:56

You don't have any code (unless there is more here) in your registration that will flush the permalinks. Go to settings/peramlinks, and click save. This should make the links work.

If you want code that will add to the cpt creation to do this automatically, let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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