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.