WooCommerce에서 제품 범주에 대한 특정 Woo 템플릿을 만들려고합니다.카테고리 별 WooCommerce 사용자 정의 테마
여기 안내를 따르려고했지만 나에게 적합하지 않습니다. Woocommerce single product - template by categories
나는 또한 이것을 발견했지만 작동시키지 못했습니다. http://wordpress.org/support/topic/plugin-woocommerce-excelling-ecommerce-a-custom-single-product-template
내 테마에는 재정의하려는 특정 템플릿 파일이있는 woocommerce 폴더가 있습니다. 여기
theme/woocommerce/single-product.php
theme/woocommerce/content-single-product.php
theme/woocommerce/content-single-product-custom-1.php
는 타겟팅 할 특정 제품에 대한 구애에 나는 사용자 정의-1 카테고리 설정이 단일 product.php
<?php if (is_product_category('custom-1')) {
wc_get_template_part('content', 'single-product-custom-1');
}
elseif (is_product_category('promise') {
wc_get_template_part('content', 'single-product-custom-2');
}
else{
wc_get_template_part('content', 'single-product');
}
?>
의 일부입니다.
content-single-product-custom-1.php을 편집 할 때 아무 것도 변경되지 않습니다. 그러나 content-single-product.php를 변경하면 해당 내용이 표시됩니다.
왜 내 제품 카테고리를 타겟팅 할 수 없습니까?
미리 감사드립니다.
를 참조 할 수 있습니다 내가 제대로 분류 조건을 추가 아니에요 가능할 것이다 ... 난 당신의 코드를 시도했지만 여전히 작동하지 않습니다? 나는 "custom-1"을 우 카테고리의 카테고리로 추가하려고 시도했지만 아직 태그로 추가하려하지 않았습니다. 게시물 ID 번호를 통해 내 맞춤 테마를 타겟팅 할 수 있습니까? – NateW
그래서 저는 모든 것을 더 잘 이해하려고 노력하고 있습니다 ... 그래서 wooCommerce는 taxonomy 용어 'product_cat'을 추가하고 다른 용어는 카테고리 용어를 기반으로합니다. – NateW
당신이 루프 외부에 있다면'print_r (get_the_terms ($ post-> id, 'product_cat'));'를 사용하거나'print_r (get_the_terms ($ product-> ID, 'product_cat')); 'product_cat'분류가 제품에 올바르게 첨부되었는지 확인하기 위해 'single-product.php'템플릿의 ' 출력을 얻지 못하면 잘못 처리합니다. – Danijel