Skip Navigation

[Resolved] Change queried post types based on view filter selections

This support ticket is created 5 years, 11 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 10 replies, has 2 voices.

Last updated by Joe 5 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#902988

Joe
search-with-agency.png
search-filter-no-agency.png
search-no-filter.png

I have a set of custom post types Resource and Agency. Agency is a parent of Resource as one Resource can be shared across multiple agencies. They both share a set of categories and tags and a couple fields. I want to create a search form that allows users to search both types. However, I would also like them to have the option of narrowing the search to only Resources for a given Agency.

So, my form has 3 filters Category, Tag and Agency. When I search on Category and Tag, everything is fine. I get any custom post associated. However, when I select an Agency, I get no results. I've added screenshots showing the output of searches. The first shows the unfiltered list, the second the list is filtered by categories, and the last adds the Agency. There should be one resource in the last list because the NOAA Sea Level resources belongs to the selected agency.

Basically, if a user selects a specific Agency from the drop down, the search function should ignore the Agency post type and focus on the Resource type only.

Also, note that I am using the beta version of types and views because it allows for many-to-many relationships. Any help would be appreciated. Thanks,
Joe

#903041

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Joe,

Thank you for contacting our support forum.

Unfortunately our Plugin does not have an inbuilt filter for Post Types so you will need to create that filter manually.

Take a look at this ticket below and it should be able to guide you through this.
https://toolset.com/forums/topic/post-type-filter/

Thanks,
Shane

#905764

Joe

I've tried the solution listed in the linked post; however, I'm still having difficulty. I think I may need to rephrase my question.
I have a View that queries two post types: Agency and Resource. Agencies are parents of Resources.

If a user selects a category in the search filters, it should show any Resource or Agency that has that category. This works fine.

Another one of the filter options I added to the page filters based on a relationship. I want to be able to filter the results by parent agency. So, if a user selects a category and an Agency, only the Resources within that Agency should show up. This breaks.

Whenever I add an Agency to the query, I get blank results. It seems like the relationship query is causing a problem. Is there a way to include a relationship query in a search for multiple post types? Thanks,
Joe

#906364

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Denise,

I understand what you are referring to now.

Would you mind providing me with admin access to the site so that I can check on this in a bit more details for you?

Thanks,
Shane

#906365

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Private fields

#906795

Joe

Yes, I've created a login on the site for you. I can post it to a private message, but I don't remember the process for doing that. Thanks,
Joe

#906954

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Denise,

Here are the private fields.

Thanks,
Shane

#907142

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Denise,

I checked on this for you and it should now be working.

Please try and let me know.

Thanks,
Shane

#907451

Joe

Hi Shane,
It is working now. Thank you. Can you tell me where the error was? I'm curious what I had done wrong. Thanks,
Joe

#907603

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Denise,

It was the relationship filter.

It was set to only perform filters for Parents of the AGENT CPT but i set the filter to Any since both CPT have the same parent information.

Thanks,
Shane

#908984

Joe

Thanks! I'm all set.

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