Skip to content

Editor: Fix sticky posts on top of every page in Query Loop Block. #8750

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2636,6 +2636,7 @@ function build_query_vars_from_query_block( $block, $page ) {

$query['offset'] = ( $per_page * ( $page - 1 ) ) + $offset;
$query['posts_per_page'] = $per_page;
$query['paged'] = $page;
}
// Migrate `categoryIds` and `tagIds` to `tax_query` for backwards compatibility.
if ( ! empty( $block->context['query']['categoryIds'] ) || ! empty( $block->context['query']['tagIds'] ) ) {
Expand Down
3 changes: 3 additions & 0 deletions tests/phpunit/tests/blocks/wpBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ public function test_build_query_vars_from_query_block_first_page() {
'tax_query' => array(),
'offset' => 0,
'posts_per_page' => 2,
'paged' => 1,
),
$query
);
Expand Down Expand Up @@ -676,6 +677,7 @@ public function test_build_query_vars_from_query_block_page_no_offset() {
'tax_query' => array(),
'offset' => 10,
'posts_per_page' => 5,
'paged' => 3,
),
$query
);
Expand Down Expand Up @@ -709,6 +711,7 @@ public function test_build_query_vars_from_query_block_page_with_offset() {
'tax_query' => array(),
'offset' => 12,
'posts_per_page' => 5,
'paged' => 3,
),
$query
);
Expand Down
Loading