Skip Navigation

[Resolved] Filter by post reference field

This support ticket is created 4 years, 2 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: Africa/Casablanca (GMT+01:00)

This topic contains 4 replies, has 3 voices.

Last updated by laszloB 4 years, 2 months ago.

Assisted by: Jamal.

Author
Posts
#1828945

There is a post type "esemeny" with a post reference field "moziterem" (post type to connect "helyszinek")
I create a view (all esemeny) : hidden link
Then I create another view with query filter: hidden link
Custom field filter: The Moziterrem is a string that is equal to the following constant: 630

The problem is: Filtered view show only old posts (with reference fields ID630)

Any idea? My database is corrupt?

#1829323

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You mean that the filter works, but only finds old posts, not recent posts?

Rather than add the filter as a custom field filter, can you delete that and replace it with a Relationship Query Filter?

The post reference field is based upon a post relationship, and if you insert a relationship filter based upon that field you can specify a single post that the results should be related to (the post with ID 630 in your example).

#1830067

Replace with a Relationship Filter is resolve my TEST view. 🙂
hidden link

But the public view where I want to use this Relationship filter there already has one 🙁
So next question: how can i use two Relationship filter at once?

#1830397

Currently, Toolset does not offer to filter a view with two relationships. However, this can still be implemented using some custom code, which is beyond the scope of this support forum.

When we use a relationship as a filter, Toolset makes sure to generate the filter and to make sure that the query will use the filter value in search.

You will need two custom codes, one for generating the filter, and the other one to hook into the view's query and change it to take into consideration the value of the filter.

For the filter, you can build a custom shortcode to generate it, for example, a custom shortcode that will generate a dropdown. Then, you will need a custom code that hooks into the view's wpv_filter_query filter and alter it.
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

#1833345

My issue is resolved...
View in view in view 🙂
Thank you!