[wp-trac] [WordPress Trac] #50885: Setting a pre_get_posts query post_type to array results in broken wp-admin filters

WordPress Trac noreply at wordpress.org
Mon Aug 10 12:46:15 UTC 2020


#50885: Setting a pre_get_posts query post_type to array results in broken wp-admin
filters
----------------------------+-----------------------------
 Reporter:  matpratta       |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  5.4.2
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 I have a in-house plugin which creates a few extra alternate post types
 (eg. `post_custom`), and one of its requirements is that these post types
 are queried together with normal posts.

 To do this, I've implemented a function which converts any queries for the
 `post` post type into `array( 'post', 'post_custom', ... )` and it works
 as it should, but when on wp-admin, if one tries to go into the default
 "Posts" menu and filter by author or even search for anything, it will
 return a message saying "Invalid post type".

 Checking the URL, it will contain the `post_type` query string as "Array"
 instead of "post", and changing it manually to "post" fixes the issue. I
 guess the wp-admin interface is not handling the array of post types
 correctly?

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


More information about the wp-trac mailing list