Thank you for sharing these details.
The 'item' attribute method ( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/ ), can only return one related post. This is why it is not effective for checking the existence of any particular related post when multiple related posts can exist.
For a conditional check like this, you'll need a custom shortcode, that can get all the related parent posts, using the 'toolset_get_related_posts' function, and then check if the target post exists in those posts or not.
( ref: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts)
For example:
add_shortcode( 'check-for-parent', 'check_for_parent_func');
function check_for_parent_func($atts) {
// target post's ID from shortcode attribute 'target'
$target_ID = $atts['target'];
// current post's ID
$postid = get_the_ID();
// setting default return value to '0'
$return_value = 0;
// get related parent posts from the current post
$get_results = toolset_get_related_posts( $postid, 'e-shop', 'child', 9999, 0, array(), 'post_id', 'parent' );
// if some parent posts are found
if(!empty($get_results)) {
// if the target post is among the found parent posts
if(in_array($target_ID, $get_results)) {
// change return value to 1
$return_value = 1;
}
}
// return the final return value
return $return_value;
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
Next, please add "check-for-parent" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.
This custom shortcode accepts one parameter 'target' which should hold the ID of the target parent post to look for:
[check-for-parent target='1234']
If the current post has this target post connected as the parent post, it will return '1' and if not, it will return '0'. This will allow you to easily construct your conditional statements, as needed.
Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/