WordPress.org

Make WordPress Core

Ticket #12743: post_type_param_for_get_page_by_title_in_post.php.diff

File post_type_param_for_get_page_by_title_in_post.php.diff, 751 bytes (added by mikeschinkel, 4 years ago)

Adds 3rd parameter to get_page_by_title() in /wp-includes/posts.php

  • post.php

     
    27962796 * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. 
    27972797 * @return mixed 
    27982798 */ 
    2799 function get_page_by_title($page_title, $output = OBJECT) { 
     2799function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page') { 
    28002800        global $wpdb; 
    2801         $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='page'", $page_title )); 
     2801        $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s", $page_title, $post_type )); 
    28022802        if ( $page ) 
    28032803                return get_page($page, $output); 
    28042804