Skip Navigation

[Resolved] Use Custom Function in a query filter – Syntax problem

This support ticket is created 6 years, 6 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by Matthias Reichl 6 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#892261
custom function in query filter.PNG

Tell us what you are trying to do?

I have a custom function [get_person_id] which holds a value which I want to use in a views query filter to compare whether it is the same as a custom field value

In the enclosed screenshot you see my query filter.

However, the view brings no results (but there are matching records)

#892495

That does not work.

The filter as you set it will look for the value "[get_person_id]" (as constant), and it will look for it in a Custom Field where you store numeric values, as it seems.

You can not build queries like this, passing a Custom ShortCode in the value to look for.

In that field, you should input the actual value you want to find

What you can do, is set to search in a "shortcode attribute".
Then, insert the View anywhere, and pass your own custom shortcode as the value of the ShortCode attribute of the View you insert.

This will then filter the results by the value you send from your Custom ShortCode to the View Query, thru the ShortCode attribute of Views.

#893896

Hi Beda!

Unfortunately I am not a very good programmer

How and where in the view do I "pass my own custom shortcode as the value of the ShortCode attribute"

#893902

Hi Beda!

I found the solution in the meantime.
Thank you for your support - it brought me on the right path