Title: Single Post 404s
Last modified: August 24, 2016

---

# Single Post 404s

 *  [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/)
 * Hey,
 * I’m hoping somebody can shed some light on an issue that I’m experiencing with
   the plugin.
 * I’m currently developing a website and have made use of the custom post types
   and taxonomies. The problem is that while the permalinks and archive/taxonomy
   pages work fine, I’m getting 404s on all singe post pages.
 * Here’s the code I’m using in my functions.php file to create the custom post 
   types:
 *     ```
       // custom post types
       add_action( 'init', 'create_post_type' );
       function create_post_type() {
           // create work post type
           register_post_type( 'work',
               array(
                   'labels' => array(
                       'name' => __( 'Work' ),
                       'singular_name' => __( 'Work' ),
                       'add_new' => __('Add New Work')
                   ),
                   'public' => true,
                   'menu_position' => 5,
                   'has_archive' => true
               )
           );
           // create blog post type
           register_post_type( 'blog',
               array(
                   'labels' => array(
                       'name' => __( 'Blog' ),
                       'singular_name' => __( 'Post' ),
                       'add_new' => __('Add New Blog Post')
                   ),
                   'public' => true,
                   'menu_position' => 5,
                   'has_archive' => true
               )
           );
       //    flush_rewrite_rules(); // dev purposes only
       }
       ```
   
 * And here’s what I’m using to create the taxonomies in the same file:
 *     ```
       // custom categories
       add_action( 'init', 'create_category' );
       function create_category() {
           register_taxonomy(
               'work-category',
               'work',
               array(
                   'label' => __( 'Work Categories' ),
                   'rewrite' => array( 'slug' => 'work' ),
                   'hierarchical' => true,
                   'show_ui' => true,
                   'show_admin_column' => true
               )
           );
           register_taxonomy(
               'blog-category',
               'blog',
               array(
                   'label' => __( 'Blog Categories' ),
                   'rewrite' => array( 'slug' => 'blog' ),
                   'hierarchical' => true,
                   'show_ui' => true,
                   'show_admin_column' => true
               )
           );
       }
       ```
   
 * Now, to me, all of the above looks okay. So, thus far, I’m stumped as to what
   the problem is.
 * Here’s how I have set up my permalinks:
 * • ‘work’ is: /%work-category%/%postname%/ (has_archive: true / with_front: true)
 * • ‘blog’ is: /%blog-category%/%postname%/ (has_archive: true / with_front: true)
 * “Use custom permalink of custom taxonomy archive” is unchecked.
 * Here’s an example how the permalinks are currently working (or not working, as
   the case may be):
 * [http://176.32.230.6/timgrewcock.com/work/](http://176.32.230.6/timgrewcock.com/work/)(
   works fine)
    [http://176.32.230.6/timgrewcock.com/work/acting/](http://176.32.230.6/timgrewcock.com/work/acting/)(
   works fine) [http://176.32.230.6/timgrewcock.com/work/acting/something-2/](http://176.32.230.6/timgrewcock.com/work/acting/something-2/)(
   doesn’t work)
 * Anybody have any ideas?
 * Thanks
 * [https://wordpress.org/plugins/custom-post-type-permalinks/](https://wordpress.org/plugins/custom-post-type-permalinks/)

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/single-post-404s/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/single-post-404s/page/2/?output_format=md)

 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973283)
 * I’m still working on this (albeit at an intermittent pace) and I’ve just discovered
   that changing the common permalink settings to default (e.g. [http://www.site.com/?p=123](http://www.site.com/?p=123))
   gets everything working.
 * So, it seems to be a problem with the postname being called.
    I’ve checked and
   I don’t have any categories or pages named the same as the two post types I created.
 * Anybody have any ideas at all?
 *  Plugin Author [Toro_Unit (Hiroshi Urabe)](https://wordpress.org/support/users/toro_unit/)
 * (@toro_unit)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973287)
 * Should not use same slug of post type and taxonomy.
 * If use same slug.
 *     ```
       /work/foo-title/
       /work/foo-term/
       ```
   
 * can not determine whether foo-title or foo-term is post-name or term-slug.
 * So, should set slug work-category to such as work/category.
 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973289)
 * Thanks for your response!
 * I think I understand what you are saying… the same word cannot be used in both
   the post type and taxonomy, right?
 * If so, I tried creating a new taxonomy that doesn’t use the word “work” but I
   still get a 404 on single posts. Here’s my new taxonomy in functions.php:
 *     ```
       register_taxonomy(
               'category-one',
               'work', // apply to 'work' post type
               array(
                   'label' => __( 'Work Categories (1)' ),
                   'rewrite' => array( 'slug' => 'work' ),
                   'hierarchical' => true,
                   'show_ui' => true,
                   'show_admin_column' => true
               )
           );
       ```
   
 * And my custom permalink now looks like: /work/%category-one%/%postname%/
 * Do you know why it still wouldn’t be working?
 * Thanks for your help.
 *  Plugin Author [Toro_Unit (Hiroshi Urabe)](https://wordpress.org/support/users/toro_unit/)
 * (@toro_unit)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973290)
 * Same word cannot be used in **slug**.
    So, Should change **$argument[“rewrite”][“
   slug”]**.
 *     ```
       register_taxonomy(
               'work-category',
               'work',
               array(
                   'label' => __( 'Work Categories' ),
                   'rewrite' => array( 'slug' => 'work/category' ),
                   'hierarchical' => true,
                   'show_ui' => true,
                   'show_admin_column' => true
               )
           );
       ```
   
 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973291)
 * Thanks for the quick reply.
 * My apologies if I’m missing something obvious, but by changing my slug to what
   you have suggested, I end up with following structure:
 * /work/ <–post type
    /work/category/acting/ <–category /work/acting/something/
   <–single post 404
 * This isn’t working for me at all, so I’m guessing I have misunderstood you?
 *  Plugin Author [Toro_Unit (Hiroshi Urabe)](https://wordpress.org/support/users/toro_unit/)
 * (@toro_unit)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973292)
 * Please tell me default permalink setting.
 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973293)
 * Common Settings is set to Post Name.
 * But I was under the impression that the default settings are disregarded as soon
   as custom settings are put in place?
 *  Plugin Author [Toro_Unit (Hiroshi Urabe)](https://wordpress.org/support/users/toro_unit/)
 * (@toro_unit)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973297)
 * OK.
 * Please Regenerate rewrite rules. Click Save in wp-admin/options-permalink.php.
 * After Regenerate rewrite rules,
    if /work/category/acting/ 404, register_taxonomy
   before _register_post_type.
 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973298)
 * Okay, I’ve saved wp-admin/options-permalink.php, so the rewrite rules have been
   flushed.
    But I’m sorry, I don’t quite understand what you meant by:
 * > After Regenerate rewrite rules,
   >  if /work/category/acting/ 404, register_taxonomy
   > before _register_post_type.
 * Can you elaborate please?
    Thanks again for your patience and help.
 *  Plugin Author [Toro_Unit (Hiroshi Urabe)](https://wordpress.org/support/users/toro_unit/)
 * (@toro_unit)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973305)
 * For now, please install [debug bar](https://wordpress.org/plugins/debug-bar/).
   And please visit the category page or single page.
 * And, please tell me the value of the “Matched Rewrite Rule”, “Matched Rewrite
   Query”.
 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973316)
 * Sure, thanks.
 * The value of “Matches Rewrite Rule” on a single post page is:
 * `work/[^/]+/([^/]+)/?$`
 * The “Matches Rewrite Query” value is:
 * `attachment=something`
 *  Plugin Author [Toro_Unit (Hiroshi Urabe)](https://wordpress.org/support/users/toro_unit/)
 * (@toro_unit)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973318)
 * Maybe you do not have commented out the flush_rewrite_rules()?
    Should not use
   flush_rewrite_rules() in your code.
 * flush_rewrite_rules is used only when Regenerate rules.
    flush_rewrite_rules 
   should be used only when RewriteRule is regenerated.
 * When I delete a comment, the problem was reproduced.
 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973319)
 * Ah yes! I forgot to comment out the flush rewrite lines.
 * I just did so, resaved options-permalink.php and went back into my Permalink 
   Settings and resaved and I’m no longer getting 404s on my single posts!
 * Thanks so much for your patience.
 * The only snag now is that my permalinks are set up as follows:
 * /work/
    /work/category/faffing/ <– here is the problem: I don’t want “category”
   in there /work/faffing/dirt-devil/
 * Is there any way to remove “category” from the taxonomy page urls?
 * Thanks so much again – at least the single posts are working now.
 *  Plugin Author [Toro_Unit (Hiroshi Urabe)](https://wordpress.org/support/users/toro_unit/)
 * (@toro_unit)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973320)
 * register_post_type and register_taxonomy add rewrite rule at last.
 * And, the priority of the rule, is determined by the order of registration.
 * If register_post_type has been executed before the register_taxonomy, post type
   rule has priority.
    So, post that post_name is faffing and parent post_name is
   category will be searched.
 * Means that you can avoid this problem by running the register_taxonomy ahead 
   register_post_type !
 *  Thread Starter [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * (@jasewarner)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/#post-5973322)
 * Okay, thanks for your response.
 * The thing is I am running register_taxonomy ahead of register_post_type.
    Here’s
   the entire block of code from my functions.php file:
 *     ```
       // custom categories
       add_action( 'init', 'create_category' );
       function create_category() {
           register_taxonomy(
               'work-category',
               'work',
               array(
                   'label' => __( 'Work Categories' ),
                   'hierarchical' => true,
                   'show_ui' => true,
                   'show_admin_column' => true,
                   'rewrite' => array( 'slug' => 'work/category' )
               )
           );
           register_taxonomy(
               'blog-category',
               'blog',
               array(
                   'label' => __( 'Blog Categories' ),
                   'hierarchical' => true,
                   'show_ui' => true,
                   'show_admin_column' => true,
                   'rewrite' => array( 'slug' => 'blog/category' ),
               )
           );
           //flush_rewrite_rules(); // dev purposes only
       }
   
       // custom post types
       add_action( 'init', 'create_post_type' );
       function create_post_type() {
           // create work post type
           register_post_type( 'work',
               array(
                   'labels' => array(
                       'name' => __( 'Work' ),
                       'singular_name' => __( 'Work' ),
                       'add_new' => __('Add New Work')
                   ),
                   'public' => true,
                   'has_archive' => true,
                   'menu_position' => 5
               )
           );
           // create blog post type
           register_post_type( 'blog',
               array(
                   'labels' => array(
                       'name' => __( 'Blog' ),
                       'singular_name' => __( 'Post' ),
                       'add_new' => __('Add New Blog Post')
                   ),
                   'public' => true,
                   'has_archive' => true,
                   'menu_position' => 5
               )
           );
           //flush_rewrite_rules(); // dev purposes only
       }
       ```
   

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/single-post-404s/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/single-post-404s/page/2/?output_format=md)

The topic ‘Single Post 404s’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-permalinks/assets/icon-256x256.png?rev=
   3495884)
 * [Custom Post Type Permalinks](https://wordpress.org/plugins/custom-post-type-permalinks/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-permalinks/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-permalinks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-permalinks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-permalinks/reviews/)

## Tags

 * [post](https://wordpress.org/support/topic-tag/post/)

 * 22 replies
 * 3 participants
 * Last reply from: [jasewarner](https://wordpress.org/support/users/jasewarner/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/single-post-404s/page/2/#post-5973387)
 * Status: not resolved