Skip Navigation

[Resolved] Filter View by a related field from great grandparent post

This support ticket is created 5 years, 11 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 18 replies, has 3 voices.

Last updated by Shane 5 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1223925

Shane,
Some of the messages above contain information like passwords which should be hidden but are not. Please review.

#1224159

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charlie,

I did some more thinking on this for you.

Lets say we have the views.

Current User
- Filter to Neighborhood A for current user. (list the neighborhood)
- -Filters Members view based on Neigborhood view result. (list the authors of the members )
--- Post view is going to be filtered by the Authors that the members view will list.

Based on this we should be able to get your results without any additional relationships because we can filter for the authors and we can use the authors to get the posts that we want.

Please let me know what you think of this.

Thanks,
Shane

#1224233

Yes, that sounds correct. I still need help understanding the details of how this gets implemented with Toolset though...

#1224565

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charlie,

Let me try my best to guide you through this process.

"View 1: A feed of all Posts authored by Members who live in the same Neighborhood as current User."

Checking on this one again, we need to have a relationship between members and neighborhood. This is because anyone can be the author of a neighborhood. So I was thinking of this is that, we create a Members view that Filters by the current user.

This will give us the member profile that relates to the current user.

We can use this to then determine the Neighborhood that they belong to. Then we create another view that will list our Members again and filter this by the Parent which is the neighborhood.

So essentially this section will only require 2 views. Two members views.

For the first view.

1. Create the first view that will list out the members.
2. Go to the query filters section and a the Post Author filter.
3. Set that post author filter to "Post author is the same as the logged in user"
4. Add the post id to the view loop output area but using the Fields and Views button.
5. Set it to "A post related to the current post, set by a Types relationship" then select neighborhood. This will allow it to select the correct neighborhood ID.

For the second Members view.
1. Create your second members view.
2. Go to the query filters section and add the "Filter by post relationship or repeatable fields group owner" filter
3. Set it to be filtered by a shortcode attribute.
4. Go to the loop output section and using the fields and view button add the Post Author to loop output section.
5. Finally you will need to add this view to the first view.

In the first view you will now need to pass the neighborhood id into the view. It will look something like this.

[wpv-view name='view-name' wpvrelatedto="[wpv-post-id item='@hood-bldg.parent']"]

This will filter your second members view to only list out the Post Authors who belong to the same neighborhood.

Finally create a 3rd view.

1. Create your post view.
2. Go to the query filter section and add a filter for Post Author.
3. Set that post author filter to "Author username is set by the View shortcode attribute "
4. Setup your view to list the information from the posts that you want.

Now we need to add this 3rd view to our 2nd members view.

So this will look something like.

[wpv-view name='view-name' author='[wpv-post-author]']

Please let me know what you think of this as this should be able to get you started.

Thanks,
Shane