I am trying to:
Trying to retrieve CPT child posts of parent CPT created via toolset, by using "toolset_get_related_posts".
And those child posts are submitted via the CRED form setting post_status as "pending".
So I need to specify post_status=any or pending together with "toolset_get_related_posts",
I think by default only status of "published" will be return though.
Link to a page where the issue can be seen: hidden link
I don't know how to set post_status parameter in "toolset_get_related_posts", which is easier than using
get_posts function as below.
$child_posts = get_posts(array(
'numberposts' => -1,
'orderby' => 'name',
'post_type' => 'event-application',
'post_status' => 'any',
'meta_query' => array(
array(
'key' => '_wpcf_belongs_event-and-seminar_id',
'value' => get_the_ID(),
'compare' => '=',
),
),
));
I think I created this relationships via Types 2, and after that I have upgraded to Types 3.
I found Toolset > Relationships menu, and found a "Run the migration" button. However I have not tried it run migration yet. Is it better to run the migration before further coding? (Of course after the DB dump)
I would suggest running the migration, except toolset_get_related_posts doesn't have any arguments for specifying the post status of the posts you wish to return.
So you may be better of sticking with the site as it is (the Types 2 relationships), where you can use get_posts and where the parent is specified in a meta query.
If you need features from Types 3 relationships, such as genuine many-to-many relationships, then you would need to run the migration.
In that case you could use toolset_get_related_posts to get the child posts, but then you would have to loop over them and discard any that did not have the required status.