Skip Navigation

[Resolved] New Post Relatsionships API – ‘call to undefined function’

This thread is resolved. Here is a description of the problem and solution.

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 support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 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)

This topic contains 16 replies, has 2 voices.

Last updated by Geoffrey Cleverley 6 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#623198

Here is the feedback from our developers:
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)

#623205

Great news, I would prefer to stay in the Beta channel...

I have been looking forward to this for a very long time. I will close this now. If I have any problems I'll just open another ticket.

Thanks