mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 13:41:24 +01:00
Add post type parameter to get_page_by_title(). props mikeschinkel, fixes #12743.
git-svn-id: http://svn.automattic.com/wordpress/trunk@13899 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f1793b308a
commit
5f50e18c0b
@ -2751,7 +2751,8 @@ function &get_page(&$page, $output = OBJECT, $filter = 'raw') {
|
|||||||
* @uses $wpdb
|
* @uses $wpdb
|
||||||
*
|
*
|
||||||
* @param string $page_path Page path
|
* @param string $page_path Page path
|
||||||
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
|
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
|
||||||
|
* @param string $post_type Optional. Post type. Default page.
|
||||||
* @return mixed Null when complete.
|
* @return mixed Null when complete.
|
||||||
*/
|
*/
|
||||||
function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
||||||
@ -2793,12 +2794,13 @@ function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
|||||||
* @uses $wpdb
|
* @uses $wpdb
|
||||||
*
|
*
|
||||||
* @param string $page_title Page title
|
* @param string $page_title Page title
|
||||||
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
|
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
|
||||||
|
* @param string $post_type Optional. Post type. Default page.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function get_page_by_title($page_title, $output = OBJECT) {
|
function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='page'", $page_title ));
|
$page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
|
||||||
if ( $page )
|
if ( $page )
|
||||||
return get_page($page, $output);
|
return get_page($page, $output);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user