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:
parent
5ca7516139
commit
770d81091d
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue