WordPress.org

Make WordPress Core

Changeset 23249


Ignore:
Timestamp:
01/03/2013 06:17:47 AM (5 years ago)
Author:
nacin
Message:

Ensure that get_archive_template() only loads a post type archive (archive-$post_type.php file) if there is exactly one post type in the query.

props scribu.
see #22956.
for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template.php

    r22634 r23249  
    6060 */
    6161function get_archive_template() {
    62     $post_types = get_query_var( 'post_type' );
    63 
    64     $templates = array();
    65 
    66     foreach ( (array) $post_types as $post_type )
     62    $post_types = array_filter( (array) get_query_var( 'post_type' ) );
     63
     64    $templates = array();
     65
     66    if ( count( $post_types ) == 1 ) {
     67        $post_type = reset( $post_types );
    6768        $templates[] = "archive-{$post_type}.php";
     69    }
    6870    $templates[] = 'archive.php';
    6971
Note: See TracChangeset for help on using the changeset viewer.