mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
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:
parent
3d4b847fbb
commit
bc8dc99e43
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user