问题
When define('WP_DEBUG', true);
and my php code
<div class="col-md-5 col-sm-5 mb-xs-30"><?php // echo single_product_summary_sale_flash();?>
<div class="fotorama" data-nav="thumbs" data-allowfullscreen="native">
<a href="#"> <?php the_post_thumbnail(); ?> </a>
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id ) {
$image_link = wp_get_attachment_url( $attachment_id ); ?>
<a href="#"><img src="<?php echo $image_link;?>" alt="Xpent Super Shop "></a>
<?php }
?>
</div>
</div>
i can see a Notice, that is Notice: WC_Product::get_gallery_attachment_ids is deprecated since version 3.0! Use WC_Product::get_gallery_image_ids instead. in D:\XAMPP\htdocs\wp\woocom\wp-includes\functions.php on line 3839 "
How to solve this problem ?
回答1:
problem solved .. just replace
$attachment_ids = $product->get_gallery_attachment_ids();
with
$attachment_ids = $product->get_gallery_image_ids();
回答2:
open file /plugins/woocommerce/includes/legacy/abstract-wc-legacy-product.php
just comment wc_deprecated_function( 'WC_Product::get_gallery_attachment_ids', '3.0', 'WC_Product::get_gallery_image_ids' );
at line no 175.
And Enjoy
来源:https://stackoverflow.com/questions/50305855/wc-productget-gallery-attachment-ids-is-deprecated-since-version-3-0