I have a one-to-many relationship between a Parent CPT and Child CPT. I have Content Templates for both. Using a View Block, it is easy to show all Children on the Parent CPT, and the Parent on a Child CPT. However what I would like to do is show all 'Siblings' on a Child CPT.
Using the latest versions of Toolset (Blocks workflow), step 3.3 on the above link does not enable the radio buttons and prompts to create a view. I cannot seem to get this to work as it did before.
Thank you for contacting us and I'd be happy to assist.
To show the related sibling posts on the child post's template, here is a simpler alternative.
1. In the template for the child post, you can create a view that shows the child post type. At this point, this view will be showing all the posts and not just the related siblings.
For example, if the ID of your view is "12345" and the relations slug is "company-branch", the code will look like this:
(you'll change these two values as per your website)
add_filter('wpv_filter_query', function($query_args, $settings, $view_id){
// get parent post's ID
$parent = do_shortcode("[wpv-post-id item='@company-branch.parent']");
// if specific view and if parent post ID exists
if ( ((isset($settings['view_id']) && $settings['view_id'] == 12345)) && (!empty($parent)) ) {
// query by related parent's connections
$query_args['toolset_relationships'][] = array(
'role' => 'child',
'related_to' => $parent,
'relationship' => 'company-branch'
);
}
return $query_args;
}, 99, 3);