我正在尝试更改我的单个产品页面的布局。为此,我需要更改文件wc-template-functions.php(在plugins/woocommerce/includes中找到)。
我知道要更改模板文件,我必须将文件夹复制到我的主题中,并将其重命名为"woocommerce",但它如何为文件夹中的文件工作?
如果您查看单个产品页面的模板,特别是content-single.php,您将看到产品图像附加到woocommerce_before_single_product_summary
钩子上。
要删除它们,您需要使用remove_action()
,然后将它们放置在其他地方,您通过add_action()
将它们连接到不同的钩子:
function so_31406339_move_images(){
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images ', 20 );
// for example, to move them to the very bottom of the page:
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_images ', 30 );
}
add_action( 'woocommerce_before_single_product', 'so_31406339_move_images' );