[wp-trac] [WordPress Trac] #55155: Cannot restrict search requests to page post type only

WordPress Trac noreply at wordpress.org
Sat Feb 12 17:35:53 UTC 2022


#55155: Cannot restrict search requests to page post type only
-------------------------------+-----------------------------
 Reporter:  bcworkz            |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  5.9
 Severity:  normal             |   Keywords:  needs-patch
  Focuses:                     |
-------------------------------+-----------------------------
 Requesting example.com/?s=foo&post_type=page returns all post types with
 "foo", not pages only. In parsing the query, the "post_type" query var
 gets dropped. Possibly because `get_post_types( array(), 'objects'
 )['page']->publicly_queryable)` returns `false`? This came up in the
 [https://wordpress.org/support/topic/restrict-search-to-post-type-page/
 support forums].

 Curiously, `is_post_type_viewable('page')` does return `true` as expected,
 even though it's supposedly relying upon the same `publicly_queryable`
 property.

 Props @ksvgn2018 for bringing this to our attention.

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


More information about the wp-trac mailing list