fixed a error when get the thumbnail by API

Fixed the error:

PHP Notice: Trying to get property of non-object in wp-includes/post-template.php on line 29
This commit is contained in:
claudiosmweb 2014-06-24 14:56:33 -03:00
parent 5ca7516139
commit 770d81091d
1 changed files with 5 additions and 4 deletions

View File

@ -106,9 +106,10 @@ class WC_Product {
if ( ! isset( $this->product_image_gallery ) ) {
// Backwards compat
$attachment_ids = get_posts( 'post_parent=' . $this->id . '&numberposts=-1&post_type=attachment&orderby=menu_order&order=ASC&post_mime_type=image&fields=ids&meta_key=_woocommerce_exclude_image&meta_value=0' );
$attachment_ids = array_diff( $attachment_ids, array( get_post_thumbnail_id() ) );
$attachment_ids = array_diff( $attachment_ids, array( get_post_thumbnail_id( $this->id ) ) );
$this->product_image_gallery = implode( ',', $attachment_ids );
}
return apply_filters( 'woocommerce_product_gallery_attachment_ids', array_filter( (array) explode( ',', $this->product_image_gallery ) ), $this );
}