From bc8dc99e433a07bddc60655a04dc2c9a2287d93c Mon Sep 17 00:00:00 2001 From: dd32 Date: Sat, 11 Dec 2010 06:35:47 +0000 Subject: [PATCH] Check to see if WP_Query has returned any posts before blindly accessing posts. Fixes #15771 git-svn-id: http://svn.automattic.com/wordpress/trunk@16872 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rewrite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 9be80de52..9bdab3601 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -337,7 +337,7 @@ function url_to_postid($url) { // Do the query $query = new WP_Query($query); - if ( $query->is_single || $query->is_page ) + if ( !empty($query->posts) && ($query->is_single || $query->is_page) ) return $query->post->ID; else return 0;