Tell us what you are trying to do? I'm trying to export a relationship but keep hitting the 100 results per post limit.
Is there any documentation that you are following?
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts-legacy
Is there a similar example that we can see?
I'm using this function in WP All Export:
<?php
function my_toolset_get_related_posts( $id ) {
$related = toolset_get_related_posts( $id, 'club-rider', array( 'query_by_role' => 'parent' ), 1000 );
if ( ! empty( $related ) && is_array( $related ) ) {
array_walk( $related, function( &$item ) {
$item = get_post_field( 'post_title', $item );
} );
return implode( '|', $related );
}
}
?>
This is the legacy version. I'm not sure how to write a non-legacy version.
What is the link to your site?
hidden link
I'm using the following plugins:
Toolset Types 3.6.0
Toolset Views 3.6.19
WP All Export Pro 1.8.6
Any thoughts or ideas most welcomed.
Kind regards
James
Hi James,
Welcome to Toolset support. We will not be able to give a working custom code, but I can try to see if I can modify your code as yours seems to be a mixture of the legacy and current mode.
According to the API docs the default limit is 100 and can be changed via the limit argument in the args array:
function my_toolset_get_related_posts( $id ) {
$related = toolset_get_related_posts(
$id,
'club-rider', //Or whatever slug that you have
array(
'query_by_role' => 'parent',
'limit' => 1000,
'return' => 'post_id',
)
);
if ( ! empty( $related ) && is_array( $related ) ) {
array_walk( $related, function( &$item ) {
$item = get_post_field( 'post_title', $item );
} );
return implode( '|', $related );
}
}
FYI: I did not test the code above so you might need to edit stuff if it does not work.
Thanks.
Hi Christopher,
That worked! Many thasnk for your help. Much appreciated.
Kind regards
James