[wp-trac] [WordPress Trac] #50070: 'post_type' query variable not set for taxonomy queries

WordPress Trac noreply at wordpress.org
Sun May 3 17:12:20 UTC 2020


#50070: 'post_type' query variable not set for taxonomy queries
--------------------------+-----------------------------
 Reporter:  aurovrata     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  5.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When a standard taxonomy query is executed on the front-end (for example
 loading a category term archive page to see all posts associated with that
 term), the `$wp_query` object constructed in the `get_posts()` function
 omits the `post_type` query variable.

 The `$q['post_type']` is empty initially (line 1848 wp-includes/class-wp-
 query.php), however, when the query is identified as a taxonomy query, a
 search is done to find which post_type is registered with this taxonomy
 (line 2132 wp-includes/class-wp-query.php) and the `$post_type` is set
 within the scope of the function, but the referenced query variable
 `$q['post_type']` isn't updated.

 this causes a problem to identify queries when hooking filters such as
 `posts_orderby` / `posts_where` / `posts_join`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50070>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list