可以在functions里添加如下代码:
- // Display description tab when empty
- add_filter( 'woocommerce_product_tabs', 'display_description_product_tabs' );
- function display_description_product_tabs( $tabs ) {
-
- $tabs['description'] = array(
- 'title' => __( 'Description', 'woocommerce' ),
- 'priority' => 10,
- 'callback' => 'woocommerce_product_description_tab',
- );
-
- return $tabs;
- }
-
- // Add image to description
- add_filter( 'the_content', 'add_product_image_woocommerce_description' );
- function add_product_image_woocommerce_description( $content ) {
- global $product;
-
- // Single product pages (woocommerce)
- if ( is_product() ) {
-
- ob_start(); // Start buffering
-
- // HERE your main image
- echo $product->get_image( array('700', '600'), array( "class" => "img-responsive" ), '' );
-
- $image_content = "";
-
- // Loop through gallery Image Ids
- foreach( $product->get_gallery_image_ids() as $image_id ) {
-
- echo '
get_attachment_image_url($image_id, 'full') . '" alt="image_content" width="500" height="600">'; - }
-
- echo '
TEST Image content
'; // Testing text -
- // Inserting the buffered content after
- $content .= ob_get_clean();
- }
-
- return $content;
- }
如果每张产品图要换行显示,则修改下面这行代码:
echo '<img src="'. wp_get_attachment_image_url($image_id, 'full') . '" alt="image_content" width="500" height="600">';
在 前后加上
:
echo '<br><img src="'. wp_get_attachment_image_url($image_id, 'full') . '" alt="image_content" width="500" height="600"><br>';