• 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.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trying to get property of non-object’ is closed to new replies.