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

WordPress Trac noreply at wordpress.org
Wed Feb 8 20:18:34 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):

 Replying to [comment:16 afragen]:
 > @peterwilsoncc here's what I found out. My simple query,
 >
 >
 > {{{
 > $query             = new WP_Query(
 >       [
 >               'post_type' => 'page',
 >               'title'     => $the_headers_title,
 >       ]
 > );
 >
 > }}}
 >
 > returns nothing when there is not logged in user. This is problematic as
 the plugin works on the frontend. This previously worked with
 `get_page_by_title()`.
 >
 > The post in question is a private post.

 I think I see a solution.

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


More information about the wp-trac mailing list