Skip Navigation

[Resolved] How to extend the limit when exporting relationships

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.

This topic contains 1 reply, has 1 voice.

Last updated by JamesS2731 1 day, 5 hours ago.

Assisted by: Christopher Amirian.

Author
Posts
#2839367
Screenshot 2025-12-10 at 09.02.27.png

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

#2839492

Christopher Amirian
Supporter

Languages: English (English )

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.

#2839524

Hi Christopher,

That worked! Many thasnk for your help. Much appreciated.

Kind regards
James