PHP函数调用缩略图,但我想禁用链接


PHP function calls thumbnail but i want to disable the link

我遇到以下问题:

我正在为客户端使用WordPress主题。他想让我编辑购物车页面(wooccommerce),主题使用自己的wooccommence功能。我的客户希望禁用购物车页面内的缩略图链接。

代码为:

printf( '<a href="%s">%s</a>', $_product->get_permalink( $cart_item ), $thumbnail );

出于某种原因,无论我编辑/编码什么,页面要么变成白色,要么缩略图不再出现,而是显示链接,所以我无法更改%s。。。

完整的PHP代码:

            <td class="product-thumbnail">
                <?php
                    $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
                    if ( ! $_product->is_visible() )
                        echo wp_kses_post( $thumbnail );
                    else
                        printf( '<a href="%s">%s</a>', $_product->get_permalink( $cart_item ), $thumbnail );
                ?>
            </td>

这就是HTML(检查元素)

<td class="product-thumbnail">
                        <a href="FAKELINKFAKELINK"><img width="180" height="180" src="FAKELINKFAKELINK/image.jpg/" class="attachment-shop_thumbnail wp-post-image" alt="image-alt"></a>                 </td>

还有谁有这个问题?或者我该如何解决?

谢谢!

要从该页面删除链接,

<td class="product-thumbnail"> 
<?php 
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); 
if ( ! $_product->is_visible() ) 
echo wp_kses_post( $thumbnail ); 
else 
printf( '<a class="hidden" href="%s"></a>%s', $_product->get_permalink( $cart_item ), $thumbnail ); 
?> 
</td>

将此添加到您的css

.hidden { display: none !important; }