从 bootScore 主题中的 WooCommerce 产品页面删除侧边栏

问题描述 投票:0回答:1

我无法使用 bootScore 子主题从 WooCommerce 中的单个产品页面删除侧边栏。

我尝试的第一件事是删除我的子主题中的操作

functions.php
文件

function remove_sidebar_single_product_page() {
if ( is_product() ) {
    // for default woocommerce structure
    remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
   }
} 
add_action( 'wp', 'remove_sidebar_single_product_page' );

然后我将文件

single-product.php
复制到
bootscore-main/woocommerce/single-product.php
并尝试注释掉
  do_action( 'woocommerce_sidebar' );
行,但没有效果,所以我猜测该文件不是负责提供单一产品的文件我的 WooCommerce 商店中的页面

然后我查看了 bootScore 主题,看到一个名为

woocommerce.php
的文件,上面写着

/**
 * The template for displaying all WooCommerce pages
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site may use a
 * different template.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Bootscore
 */

在该页面上,我看到对

<?php  get_sidebar(); ?>
的调用,因此我将其注释掉,但这也没有效果。

我不知道侧边栏还可能来自哪里。我知道我可以通过 css 隐藏侧边栏,但我不想走这条路。我真的很想知道产品页面是如何组合在一起的,并且能够控制哪些模板写入 dom。

接下来我该看哪里?

php wordpress woocommerce wordpress-theming sidebar
1个回答
0
投票

侧边栏是动态的,并且由于其中的小部件而显示,如果您从侧边栏中删除所有各种小部件,那么它将不会显示,并且主要内容将跨越页面的整个宽度

© www.soinside.com 2019 - 2024. All rights reserved.