With WP_DEBUG on I'm getting the following error on the code snippet below:
Notice: Trying to get property of non-object in C:\wamp\www\wordpress\wp-content\themes\executive\admin\theme_functions.php on line 569
Line 569 is the $photos = get_children…
function ct_get_post_image() {
global $post;
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
if ($photos) {
$photo = array_shift($photos);
return wp_get_attachment_url($photo->ID);
}
return false;
}
$photo = ct_get_post_image();
Can't seem to find any solution, any help is appreciated.