mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@55207 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
21
tests/phpunit/tests/post/getPageByTitle.php
Normal file
21
tests/phpunit/tests/post/getPageByTitle.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group post
|
||||
*
|
||||
* @covers ::get_page_by_title
|
||||
*/
|
||||
class Tests_Post_GetPageByTitle extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests that `get_page_by_title()` has been deprecated.
|
||||
*
|
||||
* @ticket 57041
|
||||
*
|
||||
* @expectedDeprecated get_page_by_title
|
||||
*/
|
||||
public function test_get_page_by_title_should_be_deprecated() {
|
||||
$this->assertNull( get_page_by_title( '#57041 Page' ) );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user