Skip to content

Commit 5a4fbb2

Browse files
authored
Merge pull request #134 from ryanwelcher/fix/child-pages-not-working
Child pages trait was not being called
2 parents 27d797d + 553203f commit 5a4fbb2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

includes/Query_Params_Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Query_Params_Generator {
3131
'post_order' => 'post_order',
3232
'exclude_current_post' => 'exclude_current',
3333
'include_posts' => 'include_posts',
34-
'child_items_only' => 'child_items_only',
34+
'child_items_only' => 'post_parent',
3535
'date_query_dynamic_range' => 'date_query',
3636
'date_query_relationship' => 'date_query',
3737
'pagination' => 'disable_pagination',

includes/Traits/Post_Parent.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public function process_post_parent(): void {
2121
} else {
2222
// This is usually when this was set on a template.
2323
global $post;
24-
$this->custom_args['post_parent'] = $post->ID;
24+
if ( isset( $post ) ) {
25+
$this->custom_args['post_parent'] = $post->ID;
26+
}
2527
}
2628
}
2729
}

includes/query-loop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function ( $default_query, $block ) {
9898
\add_action(
9999
'init',
100100
function () {
101-
$registered_post_types = \get_post_types( array( 'show_in_rest' => true, 'publicly_queryable' => true ) );
101+
$registered_post_types = \get_post_types( array( 'show_in_rest' => true, 'public' => true ) );
102102
foreach ( $registered_post_types as $registered_post_type ) {
103103
\add_filter( 'rest_' . $registered_post_type . '_query', __NAMESPACE__ . '\add_custom_query_params', 10, 2 );
104104

0 commit comments

Comments
 (0)