WordPress.org

Make WordPress Core

Ticket #18750: 18750.3.diff

File 18750.3.diff, 1.7 KB (added by billerickson, 2 years ago)
  • wp-includes/post-template.php

     
    12501250 
    12511251        global $wp_query; 
    12521252 
    1253         $page = $wp_query->get_queried_object(); 
    1254         $custom_fields = get_post_custom_values('_wp_page_template',$page->ID); 
    1255         $page_template = $custom_fields[0]; 
     1253        $page_template = get_custom_page_template(); 
    12561254 
    12571255        // We have no argument passed so just see if a page_template has been specified 
    12581256        if ( empty( $template ) ) { 
     
    12671265} 
    12681266 
    12691267/** 
     1268 * Get the specific template name for a page. 
     1269 * 
     1270 * @param int $id The page ID to check. If not provided, will use current page 
     1271 * @return string The specific template name if success, bool False on failure 
     1272 */ 
     1273function get_custom_page_template( $id = '' ) { 
     1274 
     1275        global $wp_query; 
     1276        if( empty( $id ) && is_page() ) 
     1277                $id = $wp_query->get_queried_object_id(); 
     1278                 
     1279        $page_template = get_post_meta( $id, '_wp_page_template', true ); 
     1280        if( !empty( $page_template ) ) 
     1281                return $page_template; 
     1282        else 
     1283                return false; 
     1284} 
     1285 
     1286/** 
    12701287 * Retrieve formatted date timestamp of a revision (linked to that revisions's page). 
    12711288 * 
    12721289 * @package WordPress 
  • wp-includes/theme.php

     
    947947 */ 
    948948function get_page_template() { 
    949949        $id = get_queried_object_id(); 
    950         $template = get_post_meta($id, '_wp_page_template', true); 
     950        $template = get_custom_page_template(); 
    951951        $pagename = get_query_var('pagename'); 
    952952 
    953953        if ( !$pagename && $id > 0 ) {