Skip Navigation

[Resolved] Custom Search For Custom Fields

This support ticket is created 6 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 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#622350

I am trying to:
Search custom fields within views for a custom post. The custom post and custom fields were not created with types.
Link to a page where the issue can be seen:

I expected to see:
The posts information with filters applied.
Instead, I got:
The posts appear, but all of them, with no filter.

#622420

Hello,

Please elaborate the question with more details:
How do you setup the custom fields?
What field slug is it using? is it a private field? the field slug is start with "_"?
How do you want it to setup in the view's filter?

If it is a private field, the field slug is start with "_", you can show it in the Views GUI, by this:
Dashboard-> Toolset-> Settings-> Front-end Content,
click button "Select custom fields", find and enable the private field, then you will be able to add it in the Views query filter.

#622548

How do you setup the custom fields?
I created them with the pods plugin, I'm building a site for a company to sell houses. I want the users to be able to search for a property that have a type(apartment, house,etc), a location (state, city, neighborhood) and value (range >50000, >100000, etc).

What field slug is it using? is it a private field? the field slug is start with "_"?
All the fields were created with the name of the field, then _, then the word imovel. ex: "tipo_imovel","uf_imovel","municipio_imovel".

How do you want it to setup in the view's filter?
I want to setup the filter in the same page as the query. The user select the parameters in the search with several dropdown lists, and then click to search. After the search the list of realty states properties are updated for the parameters selected.

If it is a private field, the field slug is start with "_", you can show it in the Views GUI, by this:
Dashboard-> Toolset-> Settings-> Front-end Content,
click button "Select custom fields", find and enable the private field, then you will be able to add it in the Views query filter.

I was able to add them in the query filter. The problem was that the filters were not working. I had two custom posts marked as houses and one marked as a apartement. When I filtered just by the apartment type, all three showed on the loop.

#622787

For the question: The problem was that the filters were not working
It depends on how does the pods plugin store the custom fields values, I suggest you use some MYSQL tools, check it in your database, find the custom fields value: "tipo_imovel","uf_imovel","municipio_imovel".
Then setup the custom field filter in view by following our document:
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/
Filtering Views Query by Custom Fields