WordPress.org

Make WordPress Core

Ticket #21053: template.php.patch

File template.php.patch, 894 bytes (added by jfarthing84, 6 years ago)

Reverse order of attachment template hierarchy.

  • wp-includes/template.php

     
    303303 */
    304304function get_attachment_template() {
    305305        global $posts;
    306         $type = explode('/', $posts[0]->post_mime_type);
    307         if ( $template = get_query_template($type[0]) )
     306
     307        $type = explode( '/', $posts[0]->post_mime_type );
     308
     309        if ( $template = get_query_template( "$type[0]_$type[1]" ) )
    308310                return $template;
    309         elseif ( $template = get_query_template($type[1]) )
     311        elseif ( $template = get_query_template( $type[1] ) )
    310312                return $template;
    311         elseif ( $template = get_query_template("$type[0]_$type[1]") )
     313        elseif ( $template = get_query_template( $type[0] ) )
    312314                return $template;
    313315        else
    314                 return get_query_template('attachment');
     316                return get_query_template( 'attachment' );
    315317}
    316318
    317319/**