I'll try to explain how I want this to work, rather than what I've done so far, as nothing seems to work.

I want 3 custom post types:

  • Products
  • Consumables
  • Accessories

with the following slugs:

  • example.com/products/post-name
  • example.com/products/consumables/post-name
  • example.com/products/accessories/post-name

Each of the post types will need a custom archive page, ie. actual page that can be edited by the user.

Both accessories and consumables would need to be hierarhial, as I have sub-categories for both. I have considered using taxonomies for this, but that presents the same problem: I need an overview page that can be edited by the user (in the WYSIWYG editor), on the apropriate URL.

I have currently done the overview pages as such

example.com/products - is a regular page with name and slug: "products" example.com/products/consumables - is a product with name and slug: "consumables"

ie. every overview page is situated in the root just above the appropriate post type, which is just so counterintuitive. To edit the consumables page, you go in to "products", not "consumables".

My biggest problem is that if I just define the rewrite slugs as above, only one of the post types will actually work, seemingly a random one, but I guess it has something to do with rewrite priorities. For example, all Products pages will work, but none of the Consumables or Accessories pages will.

Here's an example of the CPT code for the Product CPT:

register_post_type('product', array(
    'label' => 'Products',
    'description' => 'Product',
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'capability_type' => 'page',
    'map_meta_cap' => true,
    'hierarchical' => true,
    'rewrite' => array('slug' => 'products', 'with_front' => 0),
    'query_var' => true,
    'supports' => array('title', 'editor', 'custom-fields', 'revisions', 'thumbnail', 'page-attributes'),
    'labels' => array(
        'name' => 'Products',
        'singular_name' => 'Product',
        'menu_name' => 'Products',
        'add_new' => 'Add Product',
        'add_new_item' => 'Add New Product',
        'edit' => 'Edit',
        'edit_item' => 'Edit Product',
        'new_item' => 'New Product',
        'view' => 'View Product',
        'view_item' => 'View Product',
        'search_items' => 'Search Products',
        'not_found' => 'No Products Found',
        'not_found_in_trash' => 'No Products Found in Trash',
        'parent' => 'Parent Product',

The two others, Consumables and Accessories, would be similar with the rewrite slug being 'products/consumables', or 'products/accessories'

My hope is that I can fix this by making some custom rewrite rules that will override whatever is messing this up, but I have never tried that before, and I'm not sure that would be the solution.



  • Add your post type registration code to your question to show what you've tried. – Milo Jan 8 '14 at 14:51
  • I added an example of the CPT code currently used, and which causes the problem, with all 3 CPT's use a slug starting with 'products' – Infernosaint Mar 23 '14 at 18:31
  • it doesn't appear that your products are hierarchical, try setting that to false. also try changing the order you register them- consumables and accessories first, then products last. you should be able to get this to work without adding additional rules, which wouldn't really be any different from WordPress adding the rules via post type registration. – Milo Mar 23 '14 at 22:33
  • @Milo, I added a bit about hierarchy, products need not be hierarchial, but consumables and accessories do, as I have sub-categories: example.com/products/accessories/cables/post-name – Infernosaint Mar 28 '14 at 10:40

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.