My site is a director for commercial diving schools. School can add their school to the directory with the courses they offer, the dates the courses are offered and the price.
My site structure is as follows:
1. Custom post types:
- Dive Course: holds posts for each dive course
- Dive Schools: holds posts for each dive school
- Countries: hold posts for each country that will be later used in the location filter.
- Cities: hold posts for each city that will be later used in the location filter.
2. Post relationships:
Dive Courses
-Dive school - Courses
Dive schools
-Dive school - Courses
-City - Dive School
Cities
-City - Dive School
-City - Country
Country
-City - Country
3. Intermediate post:
-Dive school - Courses relationship (I have add an intermediate post with the price, course dates)
(It seems to work well however I am unable to filter price and dates in my search)
3. Custom field:
- Parapgraph
-URL
-Image
My question is:
1) How do I filter by the intermediate post (Price and course dates)( I have added price and dates to my search page but doesn't seem to display any information. Not sure if my Query filter or view is incorrect. )
2) Is this the correct structure to follow to allow me to have listings which can each have there own courses and prices?
Hi Timothy,
Thanks for asking! I'd be happy to help.
I'll leave the first question related to the price's filter for the other ticket, where Minesh is already helping you with this.
( ref: https://toolset.com/forums/topic/multiple-products-prices-per-listing/#post-1593681 )
Focusing on the structure, it seems correct, if you're fine with performing the search on this intermediary post type "Dive school - Courses relationship" since price information is stored with that post type too.
An important point to remember is that search filters in views can only work with the direct fields attached to the main post type that is being queried and can't be extended to related posts.
This means that if you're storing price information with the intermediary post type, then the search view in which you need a price filter will need to be set to loop through this post type too.
If your original goal is to perform a search with price filter, for the Classes post type, then one alternate could have been creating a new class post for every unique class that is linked to any school, add a custom taxonomy with that post type for storing class type information and save all custom fields with this post type, rather then with intermediary post type.
I hope this makes sense.
regards,
Waqar
Hi Waqar,
My issue is I would like only the dive school to e displayed on the filter page (I don't want the dive school to be listed multiple times for every choose it offers). Also, I would like the dive school to only fill out their information once on one page instead and not have to put their information down multiple times for every course they offer.
Hi Timothy,
> My issue is I would like only the dive school to e displayed on the filter page (I don't want the dive school to be listed multiple times for every choose it offers).
- If you're performing the search on the intermediary post type, then showing its related dive school post is easy using the item attribute.
( ref: https://toolset.com/documentation/user-guides/views/views-shortcodes/item-attribute/ )
However, the repetition of a dive school post can't be avoided, in case more than one course exists that fulfills the search criteria.
A workaround, in that case, would be to include some custom CSS or script code, to hide those duplicated results.
> Also, I would like the dive school to only fill out their information once on one page instead and not have to put their information down multiple times for every course they offer.
- If you're referring to front-end post submission, a single Toolset Form can be used to add or edit a single post in a single post type at-a-time.
Therefore, to add/edit information into multiple post types, you'll need to use multiple post forms on the same page.
If you'd like to collect all the information through a single form and you're comfortable with PHP code customizations, you can use the "cred_save_data" hook and the generic fields, to manipulate collected data into multiple posts and post types:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
regards,
Waqar