Tell us what you are trying to do? updating site to the new toolset plugins and keep custom php function work correctly
Is there any documentation that you are following?
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#public-functions-for-getting-related-posts
Is there a similar example that we can see?
i don't know
What is the link to your site?
lien caché
I'm trying to understand if the following custom code (example) required an adaptation to support the new types relationship
...
//Parent Post ID
$edu_parnt_id = wpcf_pr_post_get_belongs( $post_ID, 'education-parent' );
// get all education child posts related to the parnet
$edu_chld_posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'education',
'meta_query' => array(array('key' => '_wpcf_belongs_education-parent_id', 'value' => $edu_parnt_id))
)
);
...
please note that i don't use the WP_Query() in my code at all.
Please advise,
Thanks,
David
Not if you do (on your website) use only relationships that are "old" (even if migrated).
If you plan to create new relationships you should update it.
Nowadays for the same as you do with your code you'd follow this:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/
In specific to get the related posts you'd use
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post (single post)
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts (many)
For example, the same as you have here:
$edu_chld_posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'education',
'meta_query' => array(array('key' => '_wpcf_belongs_education-parent_id', 'value' => $edu_parnt_id))
)
);
Is now this:
$parent_id == '1';//Pass the ID of the post of which you want to get related posts (usually $post->ID if you are on a current parent post...)
$edu_chld_posts = toolset_get_related_posts(
$parent_id, // get posts related to this one
'relationship-slug-here', // relationship between the posts
'parent', // get posts where $writer is the parent in given relationship
99, 0, // pagination
array(),/additional query
'post_object'//what to return
'child' //what relation side to return
);
It seems that you use a Many To Many Relationship, and get the related of the current post, then it's child.
That is like getting the related post of the current post in a new Many To Many Relationship API, as above shown.
Just, you skip the middle post type and can get to it directly, by passing the "parent", and expecting the "Childs"