Check to see if WP_Query has returned any posts before blindly accessing posts. Fixes #15771

git-svn-id: https://develop.svn.wordpress.org/trunk@16872 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-12-11 06:35:47 +00:00
parent 4c11a459f9
commit 416efb62b4
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;