Skip Navigation

[Resolved] Multiple Query Filter in Views

This thread is resolved. Here is a description of the problem and solution.

Problem:

Display in a view, dogs that belong to the same breed as the current post, and born on the same day.

Solution:

It needs two filters to view, see details here:

https://toolset.com/forums/topic/multiple-query-filter-in-views/#post-1206371

Relevant Documentation:

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

Last updated by davelow 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1206070

I am trying to:
display in a view, dogs that belong to the same breed as the current post, and born on the same day.
Link to a page where the issue can be seen:
hidden link
I expected to see:
only dogs in the same breed and dob as the current post.
Instead, I got:
all dogs in the same breed

By itself, the DOB filter works okay, however when paired with another post relationship filter, it does not filter as specified.

#1206268

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please tell me for which view you are talking about?

Do you mean the dog images you are displaying under the section "Other Shih Tzus in the community" on the following page?
=> hidden link

#1206353
Screenshot 2019-02-26 at 22.27.51.png

Hi Minesh,

Yes, I am talking about the 'same breed' view.

#1206371

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now.

I've added the view's shortcode as given under:

{!{wpv-view name='same-breed' wpvrelatedto='{!{wpv-post-id item='@breed-dog.parent'}!}'}!}

On the following content template page and I can see now correct dog entries are displayed:
=> hidden link

#1206391
Screenshot 2019-02-26 at 22.27.51.png

Hi Minesh,

Thank you for your reply.
I think you misunderstood my issue.

on dog single, i have a couple of test views.
In the community - shows all dogs
same dob - shows dogs with the same dob as the current post
the one i am working on now is
same breed, same dob - suppose to show dogs of the same breed having the same dob as the current post.
i am able to achieve same breed, but when i add same dob, nothing happens.

in the picture above, i used 2 query filters, one for same breed and another for same dob. aren't they suppose to work together?

#1207139

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - could you please check now:
=> hidden link

I've added the view as given under:

{!{wpv-view name='same-breed' dob='{!{types field='date-of-birth' output='raw'}!}{!{/types}!}' wpvrelatedto='{!{wpv-post-id item='@breed-dog.parent'}!}'}   }!}

On the following content template page and I can see now correct dog entries are displayed:
=> hidden link

#1207356

Hi Minesh,

Thanks for the reply.
The situation has gotten worse.

Venus is a Shih Tzu, so only Shih Tzus with the same DOB should appear in the view.
Shouldn't we be tackling the issue from the View's Query Filter instead?

#1207374

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - once the ticket is resolved - the private information is deleted from our server.

Could you please send me access details again.

I have set the next reply to private which means only you and I have access to it.

#1207414

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

It looks like there was a cache issue. I deleted the cached and readded the query filters and it works. Could you please confirm now.

#1208911
Screenshot 2019-03-02 at 16.56.49.png
Screenshot 2019-03-02 at 16.55.01.png

Thank you Minesh.

It works as intended now.
I understand your solution but I have a couple of questions:

Why are we using filters twice for this purpose?
Aren't the filters in 'Views' already taking care of the filtering?

#1209268

Hello,

I have checked the post view "Same Breed" in your website.

In section "Query Filter", there are two filters:
1) Filter by post relationship:
Select posts in a Breeds Dogs relationship that are related to the Post with ID set by the shortcode attribute wpvrelatedto.

This is for get related posts by Toolset post type relationship.

2) Custom field filter
Select items with field:
Date of Birth is a number equal to VIEW_PARAM(dob)

This is for get posts on custom field "Date of Birth"

Those two filters are different, you will need to setup them manually, Views won't setup them automatically.

#1211171
Screenshot 2019-03-07 at 18.26.51.png

Hi Luoyang,

Thanks for the reply.
I understand why 2 filters have to be used.
But why are the filters applied twice? Once in Views, and a 2nd time in the shortcodes.

#1211649

No, it is not the same filter applied twice, it is two different filters applied to same view twice, see the screenshot you mentioned above
The attribute "wpvrelatedto" is related to the first view filter as I mentioned above:
https://toolset.com/forums/topic/multiple-query-filter-in-views/#post-1209268
1) Filter by post relationship:
Select posts in a Breeds Dogs relationship that are related to the Post with ID set by the shortcode attribute wpvrelatedto.

The attribute "dob" is related to the second view filter:

2) Custom field filter
Select items with field:
Date of Birth is a number equal to VIEW_PARAM(dob)

#1212229

My issue is resolved now. Thank you!