Move product title above product image on Woocommerce archive pages

南笙酒味 提交于 2019-12-04 04:54:03

问题


I am trying to move the product title above the product image on the product archive page. I have managed to figure out how to move the information, but the price is moving above the image aswell.

I want only the product title to be above the product image. The price should remain below, with the add to cart button etc.

Here is my code snippet and screenshot of result so far:

remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );


回答1:


Instead try the following, where you will set the product thumbnail just after the product title:

remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 11 );

Code goes in function.php file of your active child theme (or active theme). Tested and works.

It should work for you too.




回答2:


Try this below code

Please change the code in below file

wp-content/plugins/woocommerce/templates/content-product.php

OR

wp-content/theme/yourtheme/woocommerce/templates/content-product.php

    do_action( 'woocommerce_before_shop_loop_item' );
    do_action( 'woocommerce_before_shop_loop_item_title' );
    do_action( 'woocommerce_shop_loop_item_title' );
    do_action( 'woocommerce_after_shop_loop_item_title' );
    do_action( 'woocommerce_after_shop_loop_item' );

Replace it

do_action( 'woocommerce_shop_loop_item_title' );
do_action( 'woocommerce_before_shop_loop_item' );
do_action( 'woocommerce_before_shop_loop_item_title' );
do_action( 'woocommerce_after_shop_loop_item_title' );
do_action( 'woocommerce_after_shop_loop_item' );


来源:https://stackoverflow.com/questions/51623262/move-product-title-above-product-image-on-woocommerce-archive-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!