Skip Navigation

[Resolved] How to build this post structure

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1132594

Hello,

currently I'm planning a website with self generating pages. In this case I need a hint, what's the elegant solution for this usecase.

Let's say we've a plumber company which is located at different cities and offers always the same scope of service.
The cities and services should be independent entries (custom post type or taxonomies).

What now should happen is... There should be generated own pages for all combinations of cities and services.
For example: The plumber (keyword 1) is located at Chicago (location 1) and Miami (location 2) and offers leak detection (service 1), excavating (service 2) and jetting (service 3)

Now I need the following pages automatically generated:

Plumber Chicago (generally)
Plumber Chicago Leak Detection
Plumber Chicago Excavating
Plumber Chicago Jetting
Plumber Miami (generally)
Plumber Miami Leak Detection
Plumber Miami Excavating
Plumber Miami Jetting

the url structure should be like this:
.com/plumber/chicago
and
.com/plumber/chicago/leak-detection

The amount of entries for locations and services need to be expandable. All pages for these combinations need to be generated automatically.

Whats the best way to realize this use-case?

Thanks in advance

#1132927

There are only two ways I know of to create hierarchical, multi-level directory URLs like this in WordPress without a significant amount of custom code:

- Hierarchical post types (like standard WordPress Pages)
OR
- Hierarchical taxonomy archives

Neither approach is exactly perfect based on what you described, but I can explain what you can and can't accomplish in either scenario.

If you choose to use hierarchical post types, then you would create a new custom post type for each city. This must be done manually in wp-admin. In your example, you would create a custom post type "Chicago" and another custom post type "Miami". In each of those custom post types, you must create a separate post for each service. So under the Chicago custom post type you'll create one post for Jetting, one for Excavating, and another for Leak Detection. You'll repeat the process under the Miami custom post type, creating a post for each service. So you can see this approach is not exactly automated. You are responsible for creating each custom post type and each service post. However, once the custom post types are created you can use Forms to add and remove content from the front-end of the site if needed.

If you choose the hierarchical taxonomy archives approach, the URLs will be generated automatically based on the taxonomy term slugs and the term hierarchies. You must create a separate custom taxonomy for each city, then add terms for each service to each city's custom taxonomy. Once the taxonomies and terms are added manually in wp-admin, the URLs will be created automatically. However since you are separating these service terms into different taxonomies, searching and filtering Views based on the service provided can be a challenge. This may be irrelevant if you do not plan to allow custom searches. Another potential problem is that management of taxonomy terms on the front-end of the site is not possible in Forms.

Let me know if you have questions about either approach.