WordPress.org

Make WordPress Core

Ticket #18750: 18750.4.diff

File 18750.4.diff, 1.5 KB (added by billerickson, 6 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        if ( empty( $id ) && is_page() )
     1276                $id = get_queried_object_id();
     1277               
     1278        return get_post_meta( $id, '_wp_page_template', true );
     1279}
     1280
     1281/**
    12701282 * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
    12711283 *
    12721284 * @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 ) {