Skip Navigation

[Resolved] Custom Filter

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

Problem:

Search custom address field with a dropdown field in post view.

Solution:

It is possible with a custom field filter, but you will need to setup the dropdown menu options manually, for example:

https://toolset.com/forums/topic/custom-filter-2/#post-1206745

Relevant Documentation:

https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/

This support ticket is created 5 years, 10 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 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1206615

Hi

Im building a wedding directory site where different businesses within the region can pay to have their business added to the directory.
There are different wedding categories that make up the directory, i.e. Venue, Accommodation, Photography, Wedding Cakes etc. So if my business was a cake maker, I'd be added to the Wedding Cake directory.
When listing my business there is an address field to put in my address, e.g. 10 Example RD, Hawera.

What im trying to do is when a user clicks to view a directory, e.g. Wedding dresses I want to have a dropdown filter where they can search by location. The drop down will have set location options e.g. New Plymouth, Inglewood, Stratford, Hawera.

If I user chooses to search for Hawera, I want it to search the address field of the business listing and return all listings that have Hawera in the address field.

I can add a filter in the view to search by the address field and make it a dropdown, but that means all the actual addresses are added to the dropdown, e.g. 10 Example Rd, Hawera.

I want to be able to add a generic dropdown with options that I add in, e.g. New Plymouth, Inglewood, Stratford, Hawera and when the user selects one of those locations the view will search the address field and filter all the listing that have the selected location in the address field.

Cheers
Aaron

#1206745
address-filter.JPG

Hello,

It is possible with a custom field filter, but you will need to setup the dropdown menu options manually, for example, you can create a post view:
- Query "business" posts
- in section "Search and Pagination", add a post field filter on "address", enable option "Using manually entered values", option "comparison" choose "Like", see screenshot: address-filter.JPG

It should be able to search in the "address" field.

More help:
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/
LIKE
Single value
Checks if the custom field value is similar to the compare value, using MySQL LIKE operator

#1206768
Capture-2.JPG
Capture-1.JPG

Hi Luo

Thanks for the reply.

I kind of got it to work. I created the filter and manually added the dropdown options (see attached image), but on the front end only one select option displays (see attached image).

Cheers

#1206781

I assume you are using AJAX search feature in post view.
Please try this:
Edit the view, in section "Custom Search Settings", enable option "Let me choose individual settings manually", enable option "Always show all values for inputs", and test again.

#1206782

My issue is resolved now. Thank you!

#1206786

You are welcome