Skip Navigation

[Resolved] Create a project and show list of businesses based on criteria

This support ticket is created 4 years, 5 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 5 replies, has 2 voices.

Last updated by Luo Yang 4 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1956651

Tell us what you are trying to do? I would like for a user to be able to create a project (they should be able to create multiple projects within their account). The user will have a set of checkboxes in a project form and based on their selections, they will be shown a list of businesses that meet that criteria. Similar to Angeslist.

I am thinking of creating two custom post types: Project and Business. Setting the relationship of One (project) to Many (business)... I am just not sure how to filter the business list within a project that only shows the businesses that meet the criteria.

#1957527

Hello,

You can setup relationship filter within custom search form, for example, create a page, display a view block:
- Query "Business" posts
- Filter the result by relationship between Project and Business
- In view's loop, display Business post information.

See our document:
https://toolset.com/course-lesson/creating-a-custom-search/#add-filters-based-on-post-relationships
section "Add filters based on post relationships"

#1962043

I'm not sure that is what I need exactly. I am planning to have a list of businesses, and each will have its own list of zip codes that they serve (75005, 75006, 75008, etc.). Then the customer will complete a form (which creates a project post) and they will enter their zip code. When the customer views their project post, I would like for them to see a view that lists all the businesses that serve their zip code. So basically filtering a list of businesses based on if one of their zip codes matches the customer's zip code.

#1962265

For the ZIP issue, you can try these:
1) create a new single line field "ZIP" in post type "Business":
https://toolset.com/course-lesson/creating-custom-fields/

2) Create a post form for creating new "Business" post, so your user can submit the form in front-end and create new "Business" post:
https://toolset.com/course-lesson/front-end-forms-for-adding-content/

3) Then create a page "Find a Business", display a view block, filter the result by the "ZIP" field:
https://toolset.com/course-lesson/creating-a-custom-search/

#1963017

Can there be an automatic filter inside a post? So, if I have the list of businesses on the post page, and it is automatically filtered based on the zip code entry of the post and shows only the businesses that have a matching zip code?

#1963469

Yes, it is possible.
For example, you can get the custom field "ZIP" value with types shortcode:
https://toolset.com/documentation/customizing-sites-using-php/functions/#textfield

Then pass above value to below post view as shortcode attribute:
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes

Setup above post view as below:
- Query businesses posts
- Filter by custom field "ZIP" value = shortcode attribute value
https://toolset.com/documentation/user-guides/views/filtering-views-by-custom-fields/#source-for-compare-value
Shortcode attribute The value for the filter comes from an attribute in the View shortcode