Skip to content

Commit

Permalink
Allow the query block to work on singular pages when inheriting the g…
Browse files Browse the repository at this point in the history
…lobal query (#28351)

* Allow the query block to work on singular pages when inheriting the global query

* change condition to empty()
  • Loading branch information
aristath authored Feb 2, 2021
1 parent 0927bf7 commit d89fe22
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/block-library/src/query-loop/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function render_block_core_query_loop( $attributes, $content, $block ) {
// Unset `offset` because if is set, $wp_query overrides/ignores the paged parameter and breaks pagination.
unset( $query['offset'] );
$query = wp_parse_args( $wp_query->query_vars, $query );

if ( empty( $query['post_type'] ) && is_singular() ) {
$query['post_type'] = get_post_type( get_the_ID() );
}
}
}

Expand Down

0 comments on commit d89fe22

Please sign in to comment.