Make WordPress Core


Ignore:
Timestamp:
02/08/2010 10:05:05 PM (16 years ago)
Author:
ryan
Message:

Look for single-.php templates. Add single- class to get_body_class(). Props ptahdunbar. see #12105

File:
1 edited

Legend:

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

    r13020 r13032  
    861861    global $wp_query;
    862862
    863     $id = (int) $wp_query->post->ID;
     863    $id = (int) $wp_query->get_queried_object_id();
    864864    $template = get_post_meta($id, '_wp_page_template', true);
    865865    $pagename = get_query_var('pagename');
     
    910910 */
    911911function get_single_template() {
    912     return get_query_template('single');
     912    global $wp_query;
     913
     914    $object = $wp_query->get_queried_object();
     915    $templates = array('single-' . $object->post_type . '.php', 'single.php');
     916    return apply_filters('single_template', locate_template($templates));
    913917}
    914918
     
    975979 */
    976980function locate_template($template_names, $load = false) {
    977     if (!is_array($template_names))
     981    if ( !is_array($template_names) )
    978982        return '';
    979983
    980984    $located = '';
    981     foreach($template_names as $template_name) {
     985    foreach ( $template_names as $template_name ) {
    982986        if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
    983987            $located = STYLESHEETPATH . '/' . $template_name;
     
    989993    }
    990994
    991     if ($load && '' != $located)
     995    if ( $load && '' != $located )
    992996        load_template($located);
    993997
Note: See TracChangeset for help on using the changeset viewer.