WC_Product::get_gallery_attachment_ids 自 3.0 版起已弃用 [英] WC_Product::get_gallery_attachment_ids is deprecated since version 3.0

查看:19
本文介绍了WC_Product::get_gallery_attachment_ids 自 3.0 版起已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

define('WP_DEBUG', true);和我的 php 代码

<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全球$产品;$attachment_ids = $product->get_gallery_attachment_ids();foreach( $attachment_ids 作为 $attachment_id ) {$image_link = wp_get_attachment_url( $attachment_id );?><a href="#"><img src="<?php echo $image_link;?>"alt="Xpent 超级商店"></a><?php }?>

<块引用>

我可以看到一个Notice,即Notice:WC_Product::get_gallery_attachment_ids 自版本起已弃用3.0!改用 WC_Product::get_gallery_image_ids.在 D:\XAMPP\htdocs\wp\woocom\wp-includes\functions.php 第 3839 行

如何解决这个问题?

解决方案

问题已解决 ..只需替换

$attachment_ids = $product->get_gallery_attachment_ids();

$attachment_ids = $product->get_gallery_image_ids();

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 ?

解决方案

problem solved .. just replace

$attachment_ids = $product->get_gallery_attachment_ids();

with

$attachment_ids =  $product->get_gallery_image_ids();

这篇关于WC_Product::get_gallery_attachment_ids 自 3.0 版起已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆