从 FACTORY wp 主题中的单个产品页面删除侧边栏
Removing sidebar from single product page in FACTORY wp theme
我想从 WooCommerce 单个产品页面完全禁用侧边栏,并使页面全宽。
我已经阅读并尝试了所有可用的文档,但没有可用的文档。
步骤:
将以下代码复制到functions.php
function remove_sidebar_shop() {
if ( is_product() ) {
remove_action('woocommerce_sidebar','woocommerce_get_sidebar');
echo("Test if");
}
else {
echo("Test else");
}
}
add_action('get_header','remove_sidebar_shop');
(回显部分用于调试)
将 archive-product.php
中的行 do_action('woocommerce_sidebar');
复制到 my-theme/woocommerce
后对其进行注释。
将 single-product.php
中的行 do_action('woocommerce_sidebar');
复制到 my-theme/woocommerce
后对其进行注释。
评论了整个 sidebar.php
文件。
但似乎没有任何效果。
经过几个小时的摸索,我自己找到了解决方案,
在被覆盖的单product.php中,直到现在我都在评论这行
do_action('woocommerce_sidebar');
而是评论这一行
do_action('woocommerce_after_main_content');
成功了。
干杯....
我想从 WooCommerce 单个产品页面完全禁用侧边栏,并使页面全宽。
我已经阅读并尝试了所有可用的文档,但没有可用的文档。
步骤:
将以下代码复制到functions.php
function remove_sidebar_shop() { if ( is_product() ) { remove_action('woocommerce_sidebar','woocommerce_get_sidebar'); echo("Test if"); } else { echo("Test else"); } } add_action('get_header','remove_sidebar_shop');
(回显部分用于调试)
将
archive-product.php
中的行do_action('woocommerce_sidebar');
复制到my-theme/woocommerce
后对其进行注释。将
single-product.php
中的行do_action('woocommerce_sidebar');
复制到my-theme/woocommerce
后对其进行注释。评论了整个
sidebar.php
文件。
但似乎没有任何效果。
经过几个小时的摸索,我自己找到了解决方案,
在被覆盖的单product.php中,直到现在我都在评论这行
do_action('woocommerce_sidebar');
而是评论这一行
do_action('woocommerce_after_main_content');
成功了。
干杯....