From 9f1b20ba95f48661090a39ed44e4509fe37ef93a Mon Sep 17 00:00:00 2001 From: dd32 Date: Sun, 28 Feb 2010 13:00:27 +0000 Subject: [PATCH] Use $wp_query->get_queried_object() in single_post_title(). Fixes #11731 git-svn-id: http://svn.automattic.com/wordpress/trunk@13502 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 8c8d66ac95..d72e90d76b 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -640,17 +640,17 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { * @return string|null Title when retrieving, null when displaying or failure. */ function single_post_title($prefix = '', $display = true) { - global $wpdb, $post; - if ( ! $post ) { - $p = get_query_var('p'); - $name = get_query_var('name'); - if ( intval($p) || '' != $name ) { - if ( !$p ) - $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name)); - $post = & get_post($p); - } - } - $title = apply_filters('single_post_title', $post->post_title, $post); + global $wp_query, $post; + + if ( ! $post ) + $_post = $wp_query->get_queried_object(); + else + $_post = $post; + + if ( !isset($_post->post_title) ) + return; + + $title = apply_filters('single_post_title', $_post->post_title, $_post); if ( $display ) echo $prefix . $title; else