我正在寻找一种方法将产品描述 div 移到我的 .site-inner .wrap 下方的 #container 之外
我已经取消注册了这些选项卡,并使用这些功能移动了我的描述:
//Remove all tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
//Add product description back to page after removing tabs
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 32 );
//Add div around product description
add_action('woocommerce_single_product_summary', 'hooks_open_div', 31);
function hooks_open_div() {
echo '<div class="product-description-container">';
}
add_action('woocommerce_single_product_summary', 'hooks_close_div', 33);
function hooks_close_div() {
echo '</div>';
}
Here are some screen shots of how the html code currently looks:
Here is a screen shot of how I want the html code to look:
任何帮助将不胜感激。
谢谢,
威廉
我能够稍微清理一下我的代码,并在此过程中获得一些帮助来解决我的问题。
首先,我们首先将描述添加到挂钩“woocommerce_after_main_content”。确保仅在单个产品上有条件地运行代码(因为该钩子位于任何 wc 页面/存档内),并为其指定优先级 20。这会在关闭内容和容器 div 后附加说明。
清理我的代码:
事实证明我使用钩子在描述周围添加 div 的方式是错误的。我被告知将它们放在函数 woocommerce_template_product_description() 中会更容易、更清晰。
这是我的新工作代码:
//Remove all tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
//Add product description back to page after removing tabs
function woocommerce_template_product_description() {
if( is_product() ){
echo '<div class="product-description-container"><div class="wrap">';
woocommerce_get_template( 'single-product/tabs/description.php' );
echo '</div></div>';
}
}
add_action( 'woocommerce_after_main_content', 'woocommerce_template_product_description', 20 );
谢谢,
威廉
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)