Tell us what you are trying to do? I have a many to many relationship. In this particular case I have one post which is linked to many other posts. I want to get an indexed list/array of all the linked posts. When there is only one linked post I have used the shortcode [wpv-post-id item='@slug.parent'] this works fine. When I use the same shortcode for the above case it only gives me the first linked post. How can I get the other linked posts using this shortcode?
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
Hi Igor,
Thank you for getting touch.
When using a many to many relationship and you want to get the ID of the parent you will need to use a view to get all the posts of the Parent.
From there you can display the ids using the [wpv-post-id] shortcode.
Essentially what you're going to do is go to Toolset->Views and add a new view. Then select the Parent Post type.
Under the query filter section you will add the query filter for Post Relationship and set it to filter based on the post where the view is added.
From there you can populate the view using the Loop Wizard to add the post ID.
Finally just add your view to the content template that you're using to display the child post.
Please let me know if this helps.
Thanks,
Shane
Yes thank you, I can do that but then I need to be able to address them individually by some index. For examle say all the ID are in array called $posts. I then need to address each one $posts[0], $posts[1], $posts[2], ...
Hi Igor,
The only other way to do this is by crafting some custom code using the hook below
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
Using this hook will allow you to return an array of posts in the relationship whether it be the parent or child. Crafting this into a custom shortcode will also allow you to pass various parameters into the hook that you can use to pick off individual IDs if needed.
One of the Tools that can be used to generate the framework of your shortcode is.
hidden link
Please let me know if this helps.
Thanks,
Shane
Hi Igor,
The only other way to do this is by crafting some custom code using the hook below
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
Using this hook will allow you to return an array of posts in the relationship whether it be the parent or child. Crafting this into a custom shortcode will also allow you to pass various parameters into the hook that you can use to pick off individual IDs if needed.
One of the Tools that can be used to generate the framework of your shortcode is.
hidden link
Please let me know if this helps.
Thanks,
Shane
My issue is resolved now. Thank you!