WooCommerce自定义单页

我正在尝试为WooCommerce中的单个产品页面构建自定义视图。 如果产品说的是“自定义”类别,我希望WooCommerce通过切换到自定义页面布局来检测这一点,如果产品属于该类别。</ p>

我试过这样做 将以下代码添加到single-product.php </ p>

  if(is_product_category('custom')){
wc_get_template_part('content','single-product-custom' );
} else {
wc_get_template_part('content','single-product');
}
</ code> </ pre>

我创建了一个名为'custom'的类别 '并且还创建了一个名为'conent-single-product-custom.php'的模板,但如果我将项目放在以下自定义类别中,我会收到错误:</ p>

警告:include(/home/website/public_html/wp-content/themes/theme/woocommerce/single-product-custom.php):无法打开流:/ home / website / public_html / wp中没有此类文件或目录 -includes / template-loader.php在第89行</ em> </ p>
</ div>

展开原文

原文

I am trying to build out a custom view for single product pages within WooCommerce. If a product say lives in a category called 'custom' I want WooCommerce to detect this by switching to a custom page layout if the product lives in that category.

I have tried to do this by adding the following code to single-product.php

    if (is_product_category( 'custom')) {
        wc_get_template_part( 'content', 'single-product-custom' );
    } else {
        wc_get_template_part( 'content', 'single-product' );
    }   

I have created a category called 'custom' and also created a template called 'conent-single-product-custom.php'but I get an error if I place an item in the custom category which is the following:

Warning: include(/home/website/public_html/wp-content/themes/theme/woocommerce/single-product-custom.php): failed to open stream: No such file or directory in /home/website/public_html/wp-includes/template-loader.php on line 89

duanli9001
duanli9001 我按照这些说明来完成:wordpress.stackexchange.com/questions/75906/...:
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐