Skip Navigation

[Resolved] How do I set up a parametric search filter for parent post title

This support ticket is created 7 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Christian Cox 7 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#531018

I am trying to set up a query filter to search for offices in a building. The offices are child posts, buildings are the parent.

I need to set up a parametric filter to search for office space (by size) from the child, and a via the parent post title as a text search. Is this possible?

I don't really understand how to use the attribute function if that is a possible way of doing if?

#531110

Hi, we could implement something like this but the text field for parent post title would need to be substituted with another input type. A select field, radio button group, checkbox group, etc. is fine, but a text field isn't possible here. Even if it were possible, it seems like it would introduce too many possibilities for error to be practical, in my opinion. Considering spelling errors, punctuation differences, abbreviations, etc, I don't think the search algorithm would be very effective like this.

Is there a specific reason you want to use a text input? Perhaps if I understand more about your request I can recommend another way to provide a parent filter that will work in our system and serve your users as well.

#531304
Screen Shot 2017-06-01 at 10.01.41.png
Screen Shot 2017-06-01 at 09.32.17.png

Hi, The specific reason is for the user to search a street or building name.

I do already have a field for location in the parent post that is a simple text field, but it doesn't work very well. For instance, there are 7 offices available in 3 buildings in 1 street called Margaret street. If I search 'Margaret' it only shows 4 results. If I search for 'Margaret Street' it returns only 2 results. It is possible I haven't configured it correctly, so I've included some screen shots.

Ideally, if possible I would like it to populate it dynamically, exactly like admin when you search for a parent post relationship, which works like a dream. Is this possible?

Thanks in advance for any help you can give me.

#531517

Yes, I can see how an autosuggest input would be useful here but unfortunately that is not an input type we offer in Views just yet. One suggestion I can make would be similar to the Real Estate reference site we have set up:
http://discover-wp.com/site-types/bootstrap-estate-layouts/

If you try out the demo, you can see that the State and City filters are set up to include only options with available results. In your case, you could use Street and Building instead, but the concept would be the same. This is about as close as I can get you to an autosuggest input right now. Let me know if I can help you integrate something like this. Otherwise you're a bit limited with a text input field, as you have already noticed, mostly because of the way WordPress search works.

One way to help extend the capability of searching custom fields is to add a plugin called Relevanssi. We have some more information about that here:
https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/
This can help you search using custom fields and a text search input, but it would only apply to custom fields in the post itself and not parent posts.

#531523

Thanks Christian. Unfortunately the state and city filter would not work, as they are all in the same city and all roads or buildings in one part of town.

I'll try Relevanssi but it would have to be the free version.

Just a thought, but how about adding a jquery-chosen to a select field. Is it possible to add a class to the select input? Like this example hidden link

Do you think that would work if I listed the parents?

#531541

Unfortunately the state and city filter would not work, as they are all in the same city and all roads or buildings in one part of town.
Just to be clear, I meant that you would have filters for Street Name and Building Name, not filters for City and State. When the user selects a street name in the first filter, the building options would update to include only buildings on the selected street. This was just an example to show you the functionality of filters that update to include only the available options. More info about that here:
https://toolset.com/documentation/user-guides/front-page-filters/advanced-settings-custom-search/

Just a thought, but how about adding a jquery-chosen to a select field. Is it possible to add a class to the select input?
That's a great idea, but Views isn't tested for compatibility with this plugin and I can't guarantee it will work. It also falls into the realm of custom integrations, so I can't offer much support for it. But I don't see any reason not to try it out. You can add a custom CSS class to a parent select field by adding the "class" attribute to the select field shortcode:

[wpv-control-post-ancestor type="select" default_label="Select a Project" ancestor_type="project" class="custom-class-name"]

You can find this shortcode by editing your View. It's in the Filter Controls panel. This and other shortcodes are documented here: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-post-ancestor