Ticket #23202: 23202.patch

File 23202.patch, 779 bytes (added by wpsmith, 4 months ago)
  • wp-includes/post-template.php

     
    12441244 * @return bool False on failure, true if success. 
    12451245 */ 
    12461246function is_page_template( $template = '' ) { 
    1247         if ( ! is_page() ) 
     1247        if ( ! is_page() && ! in_the_loop() ) { 
    12481248                return false; 
     1249        } elseif ( in_the_loop() ) { 
     1250                global $wp_the_query; 
     1251                $page_template = get_page_template_slug( $wp_the_query->queried_object_id ); 
     1252        } 
     1253        else { 
     1254                $page_template = get_page_template_slug( get_queried_object_id() ); 
     1255        } 
    12491256 
    1250         $page_template = get_page_template_slug( get_queried_object_id() ); 
    1251  
    12521257        if ( empty( $template ) ) 
    12531258                return (bool) $page_template; 
    12541259