A WordPress installation with a custom theme

Custom post type: product

Custom taxonomies (for product):

  • area [hospital, restaurant, cleaning, ...]
  • group: [skirts, pants, hats, jackets, ...]
  • suitability [women, men]

There is a custom product catalog page-template, with three select boxes as the search filters:

SEARCH: [area select] [group select] [suitability select] ["show" button] - When the "show" button is clicked a new page with wanted products will be shown. This is done via javascript.

Everything works fine, but the url is like this: /catalog/?area=kitchen&group=hats&suitability=men I would prefer: /catalog/kitchen/hats/men

The Problem

I was able to make this happen (partly) by using an archive-page and setting the Category base as catalog/%area%/%group%/%suitability%/%product% in WordPress Permalink Settings, but now I have a following problem:

For example, if I want to display all the kitchen hats for men, I would use: /catalog/kitchen/hats/men. But what if I want to display all the kitchen products for men (from every product group), I would like to use: /catalog/kitchen/men. Obviously, this doesn't work because there is no product group called men (it's a suitability term).

Does anyone have ideas what should I learn and from where? In the end I would like to know how this is done in code (without plugins).

All the help and suggestions much appreciated, thank you.

  • @Rarst Good points to consider. I guess I have to challenge the Rewrite API.
    – Mennea
    Dec 11, 2016 at 11:17

1 Answer 1


In general there are the following considerations and choices:

  1. Does WP do this already?

Best case scenario when use case is reasonably supported by core natively, just configure to that.

  1. Are "pretty" permalinks critical or optional?

In general GET queries are much more easier to work with, at the cost of being "ugly". Pretty permalinks look better, but for anything complex need complete custom rules developed via WP Rewrite API, which is horrible. You want a reasonable balance of how mush of the system needs to be pretty to how hard it is to implement and have robustly working.

  1. Is your structure unambiguous?

It is often missed that WP needs to correctly "guess" what pretty URL refers to to be able to resolve it into correct query variables. Very often people want structures which are horribly confusing to code and erode the difference between different types of data. That makes for a very fragile solutions which are usually notoriously bugged.

In a nutshell:

  1. work out your structure in detail
  2. determine which queries you want via pretty permalinks and which via GET queries
  3. use WP APIs in general and Rewrite API specifically to implement

Your Answer

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

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