Skip Navigation

[Resolved] Displaying Sibling Posts of a Child Post in Blocks

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

Problem:
The user has a one-to-many relationship between two CPTs, he would like to show the siblings of the child CPT on a single CPT post with Blocks.

Solution:
We can do this, but we need an unassigned Content Template to keep the context of the parent CPT.
1. Create an unassigned Content Template, this template must not be assigned to any post type.
2. Add a new View Block to show the siblings.
2.1. Choose the post type "Section/Walk", and add a relationship Query Filter for the parent "Trail/law" according to "the current post in the loop".
2.2. Add the field that you want to show for the sibling (title, etc.)
3. Create a Content Template for the child post type "Section/Walk".
3.1. Create a Classic Block.
3.2. Use the "Fields & Views" button to insert the unassigned Content Template that you have created on 1.
3.3. In the "Post selection" tab choose the "A post related to the current post, set by a Types relationship" and your relationship. Check this image http://prntscr.com/rmp87q

This support ticket is created 4 years, 9 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 3 replies, has 2 voices.

Last updated by Jens 4 years, 9 months ago.

Assisted by: Jamal.

Author
Posts
#1562655

I'm trying to display Sibling Posts of a current child post in a Views Block. I have a test site using Astra and have set up Post Types "Trail" (Parent) and "Section" (Child). They are called 'LAW' and 'Walk' respectively in the test site. I have set a one-to-many relationship between LAW->Walk.

I can show all children on a LAW page: hidden link

I can show the parent on a Walk page: hidden link

What I want to show is all the siblings of a Walk, on the Walk page - using Blocks workflow. So if I'm looking at XYZ walk 1, I can see XYZ walk 2, XYZ walk 3...

I have had a look at the following link but it uses the old Views/Layouts workflow;

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-related-child-posts/

Is it possible in Blocks?

#1563011

Thank you for your feedback and for the access information.

I run a test on my local setup where I have a parent-child relationship between States and Cities, and I have the following data:
State: Marrakesh-Safi has two:
-- City: Marrakesh
-- City: Safi
And I was able to show Safi, a sibling of Marrakech within for parent state, inside Marrakesh page, check this image hidden link

I followed these steps:
1. Create an unassigned Content Template, this template must not be assigned to any post type.
2. Add a new View Block to show the siblings.
2.1. Choose the post type "Section/Walk", and add a relationship Query Filter for the parent "Trail/law" according to "the current post in the loop".
2.2. Add the field that you want to show for the sibling (title, etc.)
3. Create a Content Template for the child post type "Section/Walk".
3.1. Create a Classic Block.
3.2. Use the "Fields & Views" button to insert the unassigned Content Template that you have created on 1.
3.3. In the "Post selection" tab choose the "A post related to the current post, set by a Types relationship" and your relationship. Check this image hidden link

I hope this helps. If you found any troubles, I have already set your next reply as private to share access to your website, so I can check it closer. Please make a database backup before sharing credentials.

#1564239

You did not get the expected screen on 3.3, because you have added a view(LAW Walk Siblings View) on 3.2 instead of adding the unassigned content template(LAW Walk Siblings).

For debugging I removed some blocks from the templates. But I was able to fix it by removing the view from the classic block and adding the content template, then I was able to select the law/walks relationship.
Check my result on this screenshot hidden link

I hope this helps. And I remain at your disposal.

#1564541

Strange. I was sure I added the content template but must have done as you said. Thanks for helping out!