Skip Navigation

[Resolved] View to display more children of the same parent on the single page of a child

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

Problem: I have a parent - child post relationship set up. On the child post template, I would like to display a list of other sibling children of the same parent post.

Solution: Create a View of the child post type and add a post relationship Query Filter, where the parent post is set by a shortcode attribute. Place the View shortcode in your template and pass in the parent post's ID using the post ID shortcode and the item attribute:

[wpv-view name="your-view-slug" wpvrelatedto="[wpv-post-id item='@relationship-slug.parent']"]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/

This support ticket is created 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by anjaB 4 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1583945
Screenshot 2020-04-13 at 13.51.43.jpg

Tell us what you are trying to do?

I have a view on a Single Post of a product. Each product has a parent, the producer of that product. I would like to show more products (Children) of the same producer (Parent) on the Single Post Site. The parent I want to target is the parent of the Single Post Site on which the view is displayed.
Can you help me to use the right query filter ?

Is there any documentation that you are following?
no

Is there a similar example that we can see?
no

What is the link to your site?
Example of a single post in which the view should be displayed :
hidden link

#1584385
query-filter.png

Hello, you should create a Post Relationship Query Filter. In the settings you should choose the Producer-Product post relationship, where the parent post is set by one shortcode attribute "wpvrelatedto". See query-filter.png for an example. This tells the Query Filter to look for the parent post ID in a shortcode attribute. So you'll pass that value into the View shortcode in the Product template using the wpv-post-id shortcode and the "item" attribute to return the parent post ID. Here's an example:

[wpv-view name="your-view-slug" wpvrelatedto="[wpv-post-id item='@relationship-slug.parent']"]

You'll replace your-view-slug with the slug of your View, and you'll replace relationship-slug with the slug of the Producer - Product relationship. You can find that in Toolset > Relationships if you're not sure of it.

That should help you display other sibling Products. Let me know if you have questions about that.

#1584403

My issue is resolved now. Thank you!