[wp-trac] [WordPress Trac] #49553: Add option to get_search_form() to not include current search query in the form

WordPress Trac noreply at wordpress.org
Wed Aug 20 15:04:34 UTC 2025


#49553: Add option to get_search_form() to not include current search query in the
form
-------------------------+------------------------------
 Reporter:  joelhardi    |       Owner:  (none)
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Themes       |     Version:  5.4
 Severity:  normal       |  Resolution:  maybelater
 Keywords:               |     Focuses:  template
-------------------------+------------------------------
Changes (by mindctrl):

 * keywords:  has-patch dev-feedback close =>
 * status:  new => closed
 * resolution:   => maybelater


Comment:

 It's possible to achieve this with existing filters, though I would say
 it's not obvious and it could have other side effects.

 Example of how to do it:
 {{{#!php
 <?php
 add_filter( 'pre_render_block', function( $render, $block ) {
     if ( 'core/search' === $block['blockName'] ) {
         add_filter( 'get_search_query', function( $query ) {
             return '';
         } );
     }
     return $render;
 }, 10, 2 );
 }}}


 Having said that, since this ticket is 5 years old and we haven't had any
 other requests for this feature, I'm going to close this to help clean up
 Trac. Feel free to reopen if you think this enhancement should be added.

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


More information about the wp-trac mailing list