From b864f788531f152c28ec7111af643ad921807d78 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Sun, 27 Dec 2009 08:57:33 +0000 Subject: [PATCH] Fix notices in get_the_title() when passed an invalid id. Also ensure that the filter gets the invalid id so a plugin can supply a default title instead. Fixes #11435 props filosofo. git-svn-id: https://develop.svn.wordpress.org/trunk@12550 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post-template.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index c2c075b80e..62419bdce3 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -106,7 +106,8 @@ function the_title_attribute( $args = '' ) { function get_the_title( $id = 0 ) { $post = &get_post($id); - $title = $post->post_title; + $title = isset($post->post_title) ? $post->post_title : ''; + $id = isset($post->ID) ? $post->ID : (int) $id; if ( !is_admin() ) { if ( !empty($post->post_password) ) { @@ -117,7 +118,7 @@ function get_the_title( $id = 0 ) { $title = sprintf($private_title_format, $title); } } - return apply_filters( 'the_title', $title, $post->ID ); + return apply_filters( 'the_title', $title, $id ); } /**