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
This commit is contained in:
dd32 2010-12-11 06:35:47 +00:00
parent 3d4b847fbb
commit bc8dc99e43
1 changed files with 1 additions and 1 deletions

View File

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