悬停产品图片时显示其他产品信息(例如图片说明) [英] Display additional product information (e.g. image caption) when hovering product image

查看:191
本文介绍了悬停产品图片时显示其他产品信息(例如图片说明)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WooCommerce插件为WordPress显示我的产品。事情是,当你查看产品类别(存档),你可以看到产品名称,图像和价格,但这并不真正说明了什么产品是什么。

I'm using using the WooCommerce plugin for WordPress to display my products. The thing is, when you are viewing the product category (archive), you can see the product name, image and price, but that doesn't really say all that much about exactly what the product is.

我想要的是一些更多的信息,当您悬停产品图片时可用。有点像
是否可以检索一些有关图像的信息,我可以在WordPress媒体库中输入:title,caption alt text或description?

What I would like is for some more information to become available when you hover the product images. Something a bit like this. Would it be possible to retrieve some of the information about the image, that I can enter in the WordPress media libray: title, caption alt text or description?

您可以在这里查看网上商店。

EDIT:

我发现编辑WooCommerce插件文件夹中的content-product.php文件, p>

I found that editing the content-product.php file in the WooCommerce plugin folder, if I put this:

?>
random text
<?php

< li> 部分,我可以在产品归档页面上的产品图片上方或下方显示随机文字。所以,如果我可以用一个函数来代替,例如产品图片标题或一些自定义字段,我可以填写每个产品,这将是一个很长的路要解决问题。
所以,如果有人知道这样做的功能,请在这里分享。

somewhere inside the php tags in the <li> section of that file, I could get 'random text' to show either above or below the product image on the product archive page. So, if I could replace that with a function that would retreive for instance the product image caption or some custom field that I can fill out for each product, that would go a long way towards solving the issue. So, if anyone knows of a function that does this, please share it here.

推荐答案

hello sir just use this plugin
 https://wordpress.org/plugins/woocommerce-custom-product-data-fields/

for retrieving any costume fields do like this
Retrieving multiselect value



global $wc_cpdf;
$multiselect = $wc_cpdf->get_value($post->ID, '_mymultiselect');

foreach ($multiselect as $value) {

  echo $value;

}


Retrieving image value



global $wc_cpdf;

$image_id = $wc_cpdf->get_value($post->ID, '_myimage');

$size = 'thumbnail';

$image_attachment = wp_get_attachment_image($image_id, $size);

echo $image_attachment;

}

这篇关于悬停产品图片时显示其他产品信息(例如图片说明)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆