2 回答

TA貢獻1111條經驗 獲得超0個贊
一種方法是通過is_product()
或is_singular('product')
功能檢查它是否是單個產品,以及它是否不是顯示側邊欄。
template
另一種方法是從woocommerce插件根目錄完全復制文件夾,并將其粘貼到主題/當前主題/woocommerce 中,然后自定義single-product.php
文件。
注意:您不需要復制所有文件。您只能復制需要自定義的文件(這里是single-product.php
)。

TA貢獻1876條經驗 獲得超5個贊
您需要使用條件語句檢查您所在的頁面類型。
代碼可能看起來像
<main role="main" class="container row">
<?php if (! is_product() ){ //if not single product page ?>
<div class="col-md-2 filtersmargin">
<?php
if (is_active_sidebar('sidebar')) {
dynamic_sidebar('sidebar');
}
?>
</div>
<div class="col-md-10">
<?php }else{ // this depends on how you want your template to look ?>
<div class="col-md-12">
<?php } ?>
<div class="woocommerce">
<?php woocommerce_content(); ?>
</div>
</main><!-- /.container -->
如果您希望該列在單個產品頁面上為空,您只需更改一行:
if ( is_active_sidebar('sidebar') && ! is_product() ) {
我不確定您正在編輯哪個模板文件,因此可能值得研究一下。
旁注:如果您正在編輯 WooCommerce 插件中的文件,請記住最好將模板文件復制到您的主題/子主題中并以這種方式覆蓋它們,這樣您就可以在不丟失模板更改的情況下更新插件。
- 2 回答
- 0 關注
- 284 瀏覽
添加回答
舉報