From 5f50e18c0b05615907139caf371de5870e5da4bf Mon Sep 17 00:00:00 2001 From: nacin Date: Wed, 31 Mar 2010 08:20:28 +0000 Subject: [PATCH] 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 --- wp-includes/post.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 7ee9c5fcbd..cfc4f7e11e 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2751,7 +2751,8 @@ function &get_page(&$page, $output = OBJECT, $filter = 'raw') { * @uses $wpdb * * @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. */ 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 * * @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 */ -function get_page_by_title($page_title, $output = OBJECT) { +function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) { 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 ) return get_page($page, $output);