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

WordPress Trac noreply at wordpress.org
Sun May 17 15:53:19 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                              |  Resolution:
 Keywords:  has-patch dev-feedback 2nd-opinion  |     Focuses:
------------------------------------------------+--------------------------

Comment (by aurovrata):

 thanks for the patch submission @Howdy_McGee.  I came across another issue
 which this patch may not cover completely, as you are aware, for 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.

 however, is the taxonomy happens to be registered with more than 1
 post_type then `$post_type` is an array, but the actual query is being
 made with only 1 post_type, not multiple, and therefore the above search
 is unable to identify which post_type is being queried.

 This made me wonder if the issue faced here isn't further up the query
 chain, with the original contruct of the get_posts arguments.

 Is there a reason why taxonomy queries do not pass the post_type in the
 arguments?

 The typical scenario of user displaying a taxonomy query is the ability to
 add taxonomy term as menu items in the dashboard, and these are associated
 with a post_type, but the framework does not add it to the query.  So
 maybe changing the menu item auto-generated query arguments might be a
 better way to solve this problem?

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


More information about the wp-trac mailing list