Skip Navigation

[Resolved] How to extend the limit when exporting relationships

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

Problem:

When exporting Toolset relationships via WP All Export, the user repeatedly hit the default limit of 100 related posts per item. They were using a legacy-style call to toolset_get_related_posts() and were unsure how to increase the limit or switch to the non-legacy approach.

Solution:

The issue was resolved by using the current toolset_get_related_posts() API correctly and passing the limit argument inside the options array. Setting 'limit' => 1000 (or another higher value) allowed exporting more than 100 related posts. The function was also updated to explicitly return post IDs and then map them to post titles for export.

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

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