Skip Navigation

[Resolved] Need more documentation and examples on Query Filter

This support ticket is created 3 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)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Alok Sharma 3 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#2125441

I can't find any tutorial or good examples for filtering posts using custom fields.

I have created Products CPT and the following custom fields:

Is New?
Is Popular?
Is Discontinued?

These are individual checkboxes.

I then created an archive page and in WordPress Archive > Loop Section > Query Filters > Add Filter, I selected "Is Discontinued?" custom field but unable to decide if it would be a string, number or boolean. And then what values to specific when using checkboxes.

I went through the documentation, but couldn't find any detailed explanations or examples. It would be much appreciated if all combination of examples are provides for all the field types, operators & values.

#2125673
Screen Shot 2021-07-26 at 2.59.00 PM.png

Hello, I do not have any online documentation links available exactly like you have requested, but in general when filtering by custom field you can use the default option 'as a string' in most cases. The main exceptions are for Toolset's numeric fields, which should be compared as a "number" for best results, and for Toolset's date field type. Toolset date fields store information in Unix timestamp format, and should be compared as an "UNSIGNED" or as a "number" for best results.

The specific value you should use in the Query Filter depends on the field settings. By default, a checkbox is set to store the value 1 when checked, but it is possible to change that value. You would have to verify the settings in the custom field editor by going to Toolset > Custom Fields > Post Fields, then edit the field group containing the checkbox, and edit the checkbox field itself. You can find the exact value to use in "Value to store" (screenshot attached).

For a date field, you would specify a date by Unix timestamp value. You can convert any human readable date to timestamp using online tools like the Epoch Converter https://epochconverter.com

Let me know if you have a specific question about some other field type or data type and I will try to find the best answer for you.

#2126065

I am getting this now.

I tried "Is Discontinued?" is a number different from 1, and it worked. Earlier, it was not filtering out the products. Either it used to show no products or all the products.

Maybe you can inform the concerned person to update the documentation to include more examples and explanations. It would save everyone's time.

#2127033

Good point, I will file a request with our documentation team to update the documentation for the Query Filter options. Thanks for the report.

#2127423

My issue is resolved now. Thank you!