Skip Navigation

[Resolved] Using AND and OR is a view filter

This support ticket is created 3 years, 8 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 1 reply, has 2 voices.

Last updated by Jamal 3 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#2003153

Hi There,

I've been following this thread ......

https://toolset.com/forums/topic/filter-view-by-date-greater-than-today-or-blank-but-already-using-and/

I need help with a couple of things before being able to implement it.

1. How do I define the ID's of the first two views
2. How do I display the 3rd view, is it a short code and if so how would be best to implement it?

Many thanks in advance

#2003589

Hello and thank you for contacting the Toolset support.

I wonder if you are trying to build the same feature on that ticket or if you are just looking to combine AND and OR in a view filter? Please elaborate more on your use case, so I can give accurate advice.

In the meantime, I'll try to answer your questions:
1. How do I define the ID's of the first two views
You can use the get_view_query_results function to get the array of posts that the view will return. Then you can loop through them to get the IDs.
https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results

2. How do I display the 3rd view, is it a short code and if so how would be best to implement it?
You can display the view, either using a shortcode, or using the Toolset View block if you are in the blocks editor. The shortcode to display a view is wpv-view.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-154377

Regarding the combination of AND and OR, you can also, hook into the view's query filter(wpv_filter_query) and modify it the way it suits you. Check the following links:
- https://wordpress.stackexchange.com/questions/139289/multiple-nested-tax-query-relation/310245#310245
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

I hope this helps. Let me know if you have any questions.