We have a fix which is beautifully simple – as is usually the case with these sorts of things! 3 lines of code is all it will take ??
This has been tested on a custom post type with 76,000+ posts, with the biggest parent having 1,700 children.
In functions.php, find function cms_tpv_get_pages (around line 1252) and alter the $get_posts_args array so that it includes “fields” => “ids”, as shown below
$get_posts_args = array(
"fields" => "ids", // Memory fix - only get the ids of the post to reduce the memory hog of get_posts
"numberposts" => "-1",
"orderby" => "menu_order title",
"order" => "ASC",
// "caller_get_posts" => 1, // get sticky posts in natural order (or so I understand it anyway). Deprecated since 3.1
"ignore_sticky_posts" => 1,
// "post_type" => "any",
"post_type" => $r["post_type"],
"xsuppress_filters" => "0"
);
Next go to function cms_tpv_print_childs (around line 1328) and scroll down to around line 1353 and look for the “for” loop:
for ($i=0, $pagesCount = sizeof($arrPages); $i<$pagesCount; $i++) {
We need to replace this code:
$onePage = $arrPages[$i];
With this code:
// Start memory fix
$temp_page_id = $arrPages[$i];
$onePage = get_post($temp_page_id);
// End memory fix
And that’s it! Children load fine – I haven’t tested any of the other functionality, but at least the tree loading is working without a hitch now. Will contact the author of the plugin about this and hopefully it can be an official patch so we don’t have to tinker with core functions.