I've found various questions about this issue, and I still can't get this to work.

I have a post type called "product" and a taxonomy called "type". I'd like the URL for a single product post to be:


By default, it is:


I've tried every example I've found. Some say all you have to do is set hierarchical=>true for the taxonomy rewrite, but this had no effect.

I've tried this plugin: https://wordpress.org/plugins/custom-post-type-permalinks, which allowed me to use /%type%/%postname%/ in the permalink settings for the post type. The URL structure is correct, but I always get a 404 on the single product pages when the posts are in a subcategory. I tried removing the post from the parent taxonomy and only putting them in the subcategory -- still 404. The permalink works only if the product post is assigned to the parent category only. The author provides no support on the forum. (Yes I remembered to flush the permalinks.)

So I've come here hoping someone can finally provide a working solution (plugin or no plugin).

Here is my post type and taxonomy code:

// post type
register_post_type( 'product',
            'labels' => $labels,
            'public' => true,
            'hierarchical'  => false,
            'has_archive' =>false,
            'rewrite' => array( 'slug' => 'product', 'with_front' => false ),
            'query_var' => true,
            'supports' => array( 'title', 'editor', 'thumbnail' )

// taxonomy
register_taxonomy( 'type', 'product',
        'labels' => $labels,
        'hierarchical' => true,
        'show_ui' => true,
        'show_admin_column' => true,
        'rewrite' => array( 'hierarchical' => true, 'with_front' => false ),

What can I do to achieve this? Thank you!

  • your post type is also hierarchical? – Milo Oct 7 '15 at 14:48
  • It is, but it doesn't need to be. (The posts are all level 0). Should I turn that off for the post type? @Milo – LBF Oct 7 '15 at 14:50
  • If you don't need it, then set it to false. At best, it creates rewrite rules you don't need, and at worst it could create rewrite conflicts. – Milo Oct 7 '15 at 15:01
  • Actually -- that DID fix the plugin! I turned heirarchical to false, removed all my rewrite rules and retried the plugin. It worked. It's ALWAYS something so simple. Thank you, @Milo, for pointing it out. – LBF Oct 7 '15 at 15:37
  • @Milo If you'd like to move your comment to an answer, I'll mark it correct. – LBF Oct 9 '15 at 17:38

Your Answer

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

Browse other questions tagged or ask your own question.