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

WordPress Trac noreply at wordpress.org
Wed Feb 8 23:56:19 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 needs-dev-note  |     Focuses:
--------------------------------------+----------------------------

Comment (by afragen):

 After discussing this with Peter the solution seems to be adding another
 element to the query. As such the example given to developers should
 probably be something like the following to account for differences that
 might occur between `get_post_by_title()` and using `WP_Query`.


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

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


More information about the wp-trac mailing list