[wp-trac] [WordPress Trac] #62975: Twenty Twenty-Five: Exclude sticky posts when offset is used

WordPress Trac noreply at wordpress.org
Sat May 10 16:16:43 UTC 2025


#62975: Twenty Twenty-Five: Exclude sticky posts when offset is used
---------------------------+---------------------
 Reporter:  poena          |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  6.9
Component:  Bundled Theme  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+---------------------

Comment (by freibergergarcia):

 One alternative would be to apply a filter that only fires when the query
 loop block is used.

 For that, you could leverage query_loop_block_query_vars
 (https://developer.wordpress.org/reference/hooks/query_loop_block_query_vars/),
 for example:

 {{{#!php
 <?php
 /**
  * Don't prepend sticky posts if a Query Loop block uses an offset.
  */
 add_filter(
         'query_loop_block_query_vars',
         function ( $query_vars, $block ) {
                 if ( ! empty( $query_vars['offset'] ) ) {
                         $query_vars['ignore_sticky_posts'] = true;
                 }

                 return $query_vars;
         },
         10,
         2
 );
 }}}

 Obs: that would only apply when offset is > 0.

 We would need to validate if that will conflict with your comment
 https://core.trac.wordpress.org/ticket/62975#comment:2.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62975#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list