Problem: I have some questions about the toolset_get_related_posts API.
- I'm querying for child posts. Why do I query_by_role "parent"?
- If the result of the API is an array with one post, how do I access that one post without a foreach loop?
- Can you update the documentation to be more helpful?
Solution:
- You should use query_by_role "parent" when the known post is the parent post and you want to retrieve child posts.
- You can access an array item by zero-based index using the syntax here:
$item = $array[0];
- I've asked for some documentation updates here and our team will make the necessary improvements.
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
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 5 years, 7 months ago.
Assisted by: Christian Cox.