Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Feb 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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