WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/28/2010 01:00:27 PM (11 years ago)
Author:
dd32
Message:

Use $wp_query->get_queried_object() in single_post_title(). Fixes #11731

File:
1 edited

Legend:

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

    r13487 r13502  
    641641 */
    642642function single_post_title($prefix = '', $display = true) {
    643     global $wpdb, $post;
    644     if ( ! $post ) {
    645         $p = get_query_var('p');
    646         $name = get_query_var('name');
    647         if ( intval($p) || '' != $name ) {
    648             if ( !$p )
    649                 $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name));
    650             $post = & get_post($p);
    651         }
    652     }
    653     $title = apply_filters('single_post_title', $post->post_title, $post);
     643    global $wp_query, $post;
     644
     645    if ( ! $post )
     646        $_post = $wp_query->get_queried_object();
     647    else
     648        $_post = $post;
     649
     650    if ( !isset($_post->post_title) )
     651        return;
     652
     653    $title = apply_filters('single_post_title', $_post->post_title, $_post);
    654654    if ( $display )
    655655        echo $prefix . $title;
Note: See TracChangeset for help on using the changeset viewer.