From f15a669b0273464cb70c4422be697a07c9df650b Mon Sep 17 00:00:00 2001 From: rsm0128 Date: Mon, 30 Jun 2025 12:23:57 -0400 Subject: [PATCH] Added supress_filter = true to child search --- includes/utils/class-post.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/includes/utils/class-post.php b/includes/utils/class-post.php index 57b09f3..5f692c3 100644 --- a/includes/utils/class-post.php +++ b/includes/utils/class-post.php @@ -113,8 +113,9 @@ function ( $sibling ) use ( $post ) { if ( in_array( 'children', $additional_fields ) ) { $query_params = array( - 'post_parent' => $post->ID, - 'post_type' => $post->post_type, + 'post_parent' => $post->ID, + 'post_type' => $post->post_type, + 'suppress_filters' => true, ); // Default order is menu_order for hierarchical post types such as page. @@ -147,14 +148,19 @@ function ( $sibling ) use ( $post ) { $depth -= 1; + $child_params = array( + 'depth' => $depth, + ); + + if ( isset( $params['per_page'] ) ) { + $child_params['per_page'] = $params['per_page']; + } + foreach ( $children as $child ) { $children_data[] = self::get_postdata( $child, $child_additional_fields, - array( - 'per_page' => $params['per_page'], - 'depth' => $depth, - ) + $child_params ); } }