Problem:
The new Post Relationships API has landed, very happy to see this:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
Details
CPTs slugs
music-release (Music Release)
music-store (Music Store)
Relationship slug
music-release-music-store
Intermediary CPT slug
music-release-music
Intermediate CPT custom field slug
wpcf-purchase-link
So on my Music Release CPT theme template I want to:
1. Display the purchase link from the intermediary cpt that links the Music Release and the Music Store
2. Display the logo from the Music Store CPT linked to in the relationship, through the intermediary (music-release-music).
Solution:
Types 2.3-b3 (beta 3) indeed didn't include the new public API, it was released only yesterday with 2.3-b4, you can download it here:
https://toolset.com/account/downloads/
Choose channel: Beta
- originally, it was intended to be released both 2.3-b4 and 2.2.22 at the same time, but there have been delays (glitches on the part of the beta version)
And you can use function toolset_get_related_posts(), like this:
$intermediary_posts = toolset_get_related_posts( get_the_ID(), //Post to query by. 'music-release-music-store', //Slug of the relationship to query by 'parent', //Name of the element role to query by. 100, //Maximum number of returned results 0, //Result offset array(),//Additional query arguments 'post_id', //Determines return type 'intermediary' // which posts from the relationship should be returned );
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
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: Asia/Hong_Kong (GMT+08:00)
Este tema contiene 16 respuestas, tiene 2 mensajes.
Última actualización por hace 6 años, 8 meses.
Asistido por: Luo Yang.