Skip Navigation

[Resolved] URL Structure

This support ticket is created 3 years, 2 months 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 3 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#2319275

Tell us what you are trying to do?
I am developing a directory site. The site will have 2 custom post types (City and Business). An example of the permalink of those is below:

mysite.com/city/austin-tx
mysite.com/business/joe-the-plumber

I have a one to many relationship with city to businesses. There will be multiple kinds of businesses. For this example, let's say that there are plumbers and electricians.

I have built a city post template that includes a view of all businesses associated with the city. That URL is mysite.com/city/austin-tx

I would like to be able to have a URL that filters for a specific type of business. For example, mysite.com/city/austin-tx/plumbers

I would like that plumber page to show only the plumbers in Austin but also allow me to write some unique content that is different than the regular austin-tx page.

I'm thinking I need to use either tags or categories but those require a different base URL (i.e., mysite.com/business-type/plumbers) which doesn't work because I only want to show plumbers in Austin.

#2320213

Hello,

There isn't such kind of built-in feature within Toolset plugins.

As a workaround, you might try with WordPress hierarchical custom post type.

For example:
1) Edit the custom post type "city", enable options "hierarchical" + "Page Attributes"
2) Add "plumbers" sub posts for each city post
3) Create a content template, for example "parent-city-info", display a post view:
- Query business posts
- Filter by post type relationship between "City" and "business"
- In view's loop, display business post information
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items
4) In single "plumbers" sub post, display above content template with item attribute, for example:
[wpv-post-body view_template="parent-city-info" item="$parent"]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
$parent is used to retrieve data from a hierarchical parent if the current post is a type of hierarchical post such as a page