I've been wasting hours and hours trying to solve a permalink issue with custom post types. It keeps returning page not found (404). When I use the default permalinks, it works, but when I switch to post-name, it breaks. I have tried changing the slug name, flush rewrite, disabling all plug-ins, a 'custom post type permalink' plug-in all to no gain.

Anyone have similar issues? I'm on the latest 4.0.1 version of WordPress and here is my code from functions.php:

function authors_post_type() {
    $labels = array(
        'name'              => _x('Authors', 'post type general name'),
        'singular_name'     => _x('Author', 'post type singular name'),
        'add_new'           => _x('Add New', 'author'),
        'add_new_item'      => __('Add New Author'),
        'edit_item'         => __('Edit Author'),
        'new_item'          => __('New Author'),
        'all_items'         => __('All Authors'),
        'view_item'         => __('View Author'),
        'search_items'      => __('Search Authors'),
        'not_found'         => __('No authors found'),
        'menu_name'         => __('Authors')
    $args = array(
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => true,
        'menu_position'     => 5,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'rewrite'            => array( 'slug' => 'authors' ),
        'capability_type'    => 'post',
        'has_archive'        => true,
        'hierarchical'       => true,
        'menu_position'      => null,
        'supports'           => array( 'title', 'editor', 'author', 'thumbnail' )
    register_post_type('authors', $args);
add_action('init', 'authors_post_type');
  • 1
    Save your permalink structure again from WordPress admin > Settings > Permalinks
    – Robert hue
    Nov 24, 2014 at 5:06

3 Answers 3


Every time while you create new post type with code (plugins do that automatically) you have to rebuild/update you permalink on Settings - Permalink.

  • 1
    Aaaarrghh! Why do I keep forgetting this? :)
    – Erenor Paz
    Feb 28, 2017 at 9:33

You can put the following code by @bainternet just after the register_post_type('authors', $args); line, and it will flush the rewrite rules and may be you can have a solution.

*   To Activate Custom Post Type Single page
*   @see http://en.bainternet.info/2011/custom-post-type-getting-404-on-permalinks
$set = get_option('post_type_rules_flased_authors');
if ($set !== true){

I checked it with create the Authors Custom post type.

I just changed the permalink structure post name to default and again default to post name.

Its working fine.

you can try it, and let me know if you have still facing this issue.

Your Answer

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

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