Skip Navigation

[Resolved] custom search across two post types, enabling user filter to select one or other

This thread is resolved. Here is a description of the problem and solution.

Problem:
Custom Search across two post types, but enable user filtering at outset to select one or other, results only show one or other according to user filter.
Solution:
Solution here with screenshots:
https://toolset.com/forums/topic/custom-search-across-two-post-types-enabling-user-filter-to-select-one-or-other/#post-565232
Relevant Documentation:

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

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by Cam Macduff 6 years, 6 months ago.

Assisted by: Noman.

Author
Posts
#565094

Tell us what you are trying to do? Custom Search across two post types, but enable user filtering at outset to select one or other, results only show one or other according to user filter.

Is there any documentation that you are following? custom searches

Is there a similar example that we can see? I've tried setting it up here: hidden link

What is the link to your site? hidden link

#565131

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Cam,

Thank you for contacting Toolset support. I would like to get clear idea on your requirements, there are some confusions:

1. Post type filter in View, have you added it using custom code? Because we don’t have this filter.

2. Do you want to add a dropdown or a field in the Custom Search View >> to list all posts Authors (users) >> so that people can search by post Authors?

3. OR do you want to make “Vets Or Practices” field required and people must select it first to serach?

4. Practice, Vet = these are Categories or Custom Post Types?

Please provide these details, screenshots will also help to clarify the requirements. Thank you

#565167
Screen Shot 2017-08-30 at 11.47.50 pm.png

Hi Norman,
1. No, I've simply used a query filter for taxonomy and displayed it as a dropdown. But I don't think it's working anyway. See attached.

2. No, I don't want to search by users.

3. Yes, I want to force web site visitors to make a choice on what they search for first; vets for practices. Then they just get a free text field to search all toolset fields. I'm using Relvenissi so Toolset can search all fields.

4. Practice, Vet are both Custom Posts and Categories. I add the Category so I could create the taxonomy query filter, but originally I was trying to avoid having a taxonomy for these to custom post types.

What I"m trying to do is avoid having seperate search pages for these two custom post types.
If it were possible, I'd have a tabbed view cell at the top of the page. One tab labelled Vets and the other Practices. Toggling the tabs would reveal a different set of query filters appropriate to each data set.

But as I don't think that's possible, I was trying to find a way to force people to make a choice from a radio button or dropdown - then use a free text field search all toolsets custom fields.
I was also hoping this would filter the results below according to their choice so it only listed results for vets OR practices.

Can you advise if what I'm attempting is possible or if there's a better way to do it?
Thanks in advance.
Cam

#565232

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

3. Ajax results option.png
4. Results.png

Thank you for providing more details.

“ What I"m trying to do is avoid having separate search pages for these two custom post types.
If it were possible, I'd have a tabbed view cell at the top of the page. One tab labelled Vets and the other Practices. Toggling the tabs would reveal a different set of query filters appropriate to each data set. “

This one is possible, steps would be as follows:

1. Create 2 Custom Search Views -- one for each Post type.
2. Using Layouts plugin >> add a Tab cell into it >> and in each Tab insert the View. One for Vets and second for Practices in separate tabs.
3. Please make sure to also enable “Ajax results update…” option for both Views, screenshot attached.
4. The Result will be something like in the attached screenshot.

OR if you are not using Layouts, you can also insert Bootstrap tabs directly into the page like this:

<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="tab" href="#students">Students</a></li>
  <li><a data-toggle="tab" href="#books">Books</a></li>
</ul>

<div class="tab-content">
  <div id="students" class="tab-pane fade in active">
    [wpv-view name="student-term-search"]
  </div>
  <div id="books" class="tab-pane fade">
    [wpv-view name="book-term-filter"]
  </div>
</div>

I hope this helps, Thank you

#567425

That worked! Thank you!

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