1. Home
  2. Docs
  3. Features
  4. How to make hierarchical post types & taxonomies permalinks flat?

How to make hierarchical post types & taxonomies permalinks flat?

Wordpress allows to use both hierarchical and non-hierarchical (post-like) post types and taxonomies. In some particular cases it is wiser to keep the content types hierarchical (eg. for easier admin management) and make the URLs shorter (by removing the parents’ slugs from child permalinks) for better SEO performance.

Sample hierarchical permalinkSample flat (non-hierarchical) permalink
Cars
(hierarchical post type)
http://example.com/car/ford/ford-fiestahttp://example.com/ford-fiesta
Brands
(hierarchical post type)
http://example.com/car-brand/american-cars/fordhttp://example.com/ford

If you would like to make the hierarchical post types & taxonomies permalinks flat (non-hierarchical_ you will need to go to “Tools -> Permalink Manager -> Permastructures” section.

How to make hierarchical post types permalinks non-hierarchical?

By default the permastructure tag for posts, pages or custom post types slugs will be set to either %postname% or %custom-post-type-name% (eg. %car%).

If you would like to use only the actual post slug and do not include the parent pages/posts slugs to the permalink, you will need to replace it with either %postname_flat% or %{custom-post-type-name}_flat% (eg. %car_flat%).

“Cars” posts permalinks will always be flat (non-hierarchical) and they will not inherit the slugs assigned to their parents.

How to make hierarchical terms permalinks non-hierarchical?

By default the permastructure tag for categories, terms or custom taxonomies slugs will be set to either %term% or %custom-taxonomy-name% (eg. %car-brand%).

If you would like to use only the actual term slug and do not include the parent slugs to the permalink, you will need to replace it with either %term_flat% or %{custom-taxonomy-name}_flat% (eg. %car-brand_flat%).

How to make hierarchical term permalinks non-hierarchical inside post permalinks?

If you would like to append the single non-hierarchical term slug to the post, page or custom post type permalink you will need to add %{custom-taxonomy-name}_flat% (eg. %product_cat_flat%) tag to permastructure settings field for selected custom post types.

Sample hierarchical permalinkSample flat (non-hierarchical) permalink
Products
with product categories
http://example.com/shop/clothing/t-shirts/happy-ninjahttp://example.com/t-shirts/happy-ninja

How to apply the new settings to old permalinks?

The new permastructures will be automatically applied to the new posts & terms. To reset the old permalinks please go to “Tools -> Permalink Manger -> Tools -> Regenerate/reset” page (see more detailed instructions here) or adjust them individually (using “Restore to Default URI” button inside Edit URI box on “Edit Post/Page/CPT” admin page).

Was this article helpful to you? Yes No