Skip Navigation

[Resolved] Trying to create a business directory with multiple towns (each business has CPT

This support ticket is created 7 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

Author
Posts
#441850

I am trying to:

Build a regional directory of businesses based on multiple towns. Each business can have several different CPT children (events, promotions etc.)

So a business will look like this:

business1
- Event1
- Event2
- Promotion1
- Promotion2
- Promotion3

I'd like to be able to present the following front end views:

Town-wide lists
/towna/businesses/ --> A list of all the businesses in town A
/towna/events/ --> A list of all events in town A
/towna/promotions/ --> A list of all promotions in town A

Town + category lists
/towna/businesses/cafes/ --> A list of all cafes (based on business category)
/towna/events/cafes/ --> A list of all events run by cafes (based on business category)
/towna/promotions/cafes/ --> A list of all promotions in cafes (based on business category)

Business-specific lists
/towna/business1/events --> Business1's events
/towna/business1/promotions --> Business1's promotions

Since the list of towns is short (<5) and they're not hierarchical (i.e. no town is a subset of another town), I could create a "town" CPT and set all businesses as children. However, it feels like Taxonomies are the right fit for this use case.

Please could you give me some guidance whether I should use a town "parent" CPT or taxonomies to achieve the above. Any guidance would be great.

#442493

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi James

I agree with your own assessment, that taxonomies would work well for the towns, and the taxonomy queries would be more efficient than the hierarchical relationship queries which are based upon post meta.

To take a couple of examples from your question:

/towna/businesses/cafes/, you would have a View to show businesses with the location taxonomy of towna and businesses category of cafe.

/towna/events/, you would have a View which returned businesses with location taxonomy towna. You wouldn't output anything of the businesses, your loop output would be a nested View which showed events whose parent was the current item in the loop (the output of which would doubtless refer to fields of the parent business using the id="$parent" parameter).

If you need help setting up any of the views let me know.

#442571

Hi Nigel,

Thanks for getting back to me and confirming that I'm on the right lines. I'm a complete n00b to Toolset so been doing a lot of Googling! Any help you could give me (point me to relevant examples for your suggested nesting etc) would be great. Sadly, I'm developing locally at the mo so can't give you access to my install.

Thanks,
James

#443315

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi James

Reviewing this I see you had some follow up questions even though you marked the thread as resolved, so let me re-open it to point you towards a couple of relevant pieces of documentation.

The nested loop that displays the child posts (e.g. for towna/events/), you can read more about that here: https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

For referring to fields from the parent post, see: https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

I'm assuming you have already read about setting up the parent-child relationships in the first place, but if not, start here: https://toolset.com/documentation/user-guides/creating-post-type-relationships/

If you have a general question about the set-up you can continue with this thread.

If you have specific implementation questions it would be more helpful to start a new thread (we try to keep threads to a single topic to help others researching the same issue in the forums).

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.