[wp-trac] [WordPress Trac] #60269: URL parameter filtering with 'tag' parameter

WordPress Trac noreply at wordpress.org
Wed Feb 19 07:07:32 UTC 2025


#60269: URL parameter filtering with 'tag' parameter
--------------------------+------------------------------
 Reporter:  harolair      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by oshodev):

 To enable tag URL filtering without relying on $this->query_vars_changed,
 hook into pre_get_posts and manually set the query var:

 {{{
 add_action('pre_get_posts', function($query) {
     if (!is_admin() && $query->is_main_query() && isset($_GET['tag'])) {
         $query->query_vars_changed = true; // Force query vars as changed
     }
 });

 }}}

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


More information about the wp-trac mailing list