Editor: Add option to ignore sticky posts in Query block.

Introduce a new `ignore` value for the `sticky` query argument. When this value is used, the query will not prepend sticky posts at the top but display them in the natural order.

Props mamaduka, peterwilsoncc, audrasjb, mikinc860, poena, dhruvishah2203, joemcgill.
Fixes #62908.
Built from https://develop.svn.wordpress.org/trunk@59866


git-svn-id: http://core.svn.wordpress.org/trunk@59208 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mamaduka
2025-02-25 05:12:23 +00:00
parent 802523f5d7
commit b2fdfe280c
2 changed files with 4 additions and 2 deletions

View File

@@ -2564,8 +2564,10 @@ function build_query_vars_from_query_block( $block, $page ) {
*/
$query['post__in'] = ! empty( $sticky ) ? $sticky : array( 0 );
$query['ignore_sticky_posts'] = 1;
} else {
} elseif ( 'exclude' === $block->context['query']['sticky'] ) {
$query['post__not_in'] = array_merge( $query['post__not_in'], $sticky );
} elseif ( 'ignore' === $block->context['query']['sticky'] ) {
$query['ignore_sticky_posts'] = 1;
}
}
if ( ! empty( $block->context['query']['exclude'] ) ) {

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59865';
$wp_version = '6.8-alpha-59866';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.