WooCommerce - 从产品页面删除页脚

WooCommerce - Remove footer from product page

大家好,我想从 woocommerce 产品页面中删除页脚。我找不到页面名称,所以我可以从那里删除 wp_footer 代码。

我怎样才能做到这一点?

请指导我。

您可以结合使用本机条件,is_cart()is_checkout() is_account_page(),在您的活动主题或子主题的 footer.php 文件中,通过这种方式隐藏页脚中的某些元素(对于 WooCommerce 商店页面和产品页面):

if ( !is_cart() || !is_checkout() || !is_account_page() ) { 

    // On WooCommerce shop and product pages

   // here goes CUSTOM displayed footer code for WooCommerce shop and product pages

} else { // your normal footer code

    // here goes all displayed footer code

} 

根据您想从 woocommerce 页面隐藏的内容,您必须在现有代码中对其进行调整,以满足您的需要。 但不删除wp_footer以避免出现大问题。

参考:Official WooCommerce Conditional Tags


之后,您可以 Override WooCommerce Templates via a Theme 使用我的帐户模板来微调更多 WooCommerce 行为……

您可以从 WooCommerce 产品页面删除页脚 -

 if (is_product()) {   
   // here is your footer code which you want to display on woocommerce product page
 }
 else {
    // past your all footer code here for other pages
 }

footer.php 文件中使用此代码。

If you want to learn more, you can check this - WooCommerce conditional tags