Display additional product information (e.g. image

2019-09-06 00:32发布

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.

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?

You can check the webshop here.

EDIT:

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

?>
random text
<?php

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.

1条回答
手持菜刀,她持情操
2楼-- · 2019-09-06 01:17
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;

}
查看更多
登录 后发表回答