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

git-svn-id: https://develop.svn.wordpress.org/trunk@13502 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-02-28 13:00:27 +00:00
parent 5f43ce3a7b
commit 81b675575d
1 changed files with 11 additions and 11 deletions

View File

@ -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