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
This commit is contained in:
parent
57c4fe34bd
commit
9f1b20ba95
|
@ -640,17 +640,17 @@ function wp_title($sep = '»', $display = true, $seplocation = '') {
|
||||||
* @return string|null Title when retrieving, null when displaying or failure.
|
* @return string|null Title when retrieving, null when displaying or failure.
|
||||||
*/
|
*/
|
||||||
function single_post_title($prefix = '', $display = true) {
|
function single_post_title($prefix = '', $display = true) {
|
||||||
global $wpdb, $post;
|
global $wp_query, $post;
|
||||||
if ( ! $post ) {
|
|
||||||
$p = get_query_var('p');
|
if ( ! $post )
|
||||||
$name = get_query_var('name');
|
$_post = $wp_query->get_queried_object();
|
||||||
if ( intval($p) || '' != $name ) {
|
else
|
||||||
if ( !$p )
|
$_post = $post;
|
||||||
$p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name));
|
|
||||||
$post = & get_post($p);
|
if ( !isset($_post->post_title) )
|
||||||
}
|
return;
|
||||||
}
|
|
||||||
$title = apply_filters('single_post_title', $post->post_title, $post);
|
$title = apply_filters('single_post_title', $_post->post_title, $_post);
|
||||||
if ( $display )
|
if ( $display )
|
||||||
echo $prefix . $title;
|
echo $prefix . $title;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue