[wp-trac] [WordPress Trac] #57041: Deprecate `get_page_by_title()` in favour of `WP_Query`

WordPress Trac noreply at wordpress.org
Fri Feb 3 03:56:25 UTC 2023


#57041: Deprecate `get_page_by_title()` in favour of `WP_Query`
-------------------------------+----------------------------
 Reporter:  peterwilsoncc      |       Owner:  peterwilsoncc
     Type:  enhancement        |      Status:  closed
 Priority:  normal             |   Milestone:  6.2
Component:  Posts, Post Types  |     Version:  2.1
 Severity:  normal             |  Resolution:  fixed
 Keywords:  has-patch          |     Focuses:
-------------------------------+----------------------------
Changes (by peterwilsoncc):

 * owner:  (none) => peterwilsoncc
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"55207" 55207]:
 {{{
 #!CommitTicketReference repository="" revision="55207"
 Posts, Post Types: Deprecate `get_page_by_title()` in favour of
 `WP_Query`.

 Formally deprecate `get_page_by_title()`. In its current form the function
 is unpredictable in that it may return a result that leads to a 404 error
 and will return different results depending on the database version/engine
 combination used.

 It is recommended developers use `WP_Query` instead:

 {{{
 $query = new WP_Query(
  array(
   'post_type' => 'page',
   'title'     => 'Sample Page',
  )
 );
 }}}


 Props TimothyBlynJacobs, costdev, mukesh27, spacedmonkey, peterwilsoncc.
 Fixes #57041.
 }}}

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


More information about the wp-trac mailing list