이렇게 작은 변경 사항의 경우 전체 파일을 덮어 쓸 필요가 없습니다. 먼저 WooCommerce에서 제공하는 후크를 사용해보십시오. 테마 functions.php에서이 작업을 수행 할 수 있습니다. 이 함수는 최상위 페이지 래퍼 내부에 사용자 정의 래퍼를 출력합니다. 모든 WooCommerce 페이지에 고유 한 래퍼를 추가하려면
function start_wrapper_here() { // Start wrapper
echo '<div class="custom-wrapper">';
}
add_action( 'woocommerce_before_main_content', 'start_wrapper_here', 20 );
function end_wrapper_here() { // End wrapper
echo '</div>';
}
add_action( 'woocommerce_after_main_content', 'end_wrapper_here', 20 );
, 당신은 위의 기능에 조건문을 추가하여이 작업을 수행 할 수 있습니다. 더 많은 조건부 태그에 대해서는 Visit this page on the WooCommerce site입니다.
function start_wrapper_here() { // Start wrapper
if (is_shop()) { // Wrapper for the shop page
echo '<div class="shop-wrapper">';
} elseif (is_product_category()) { // Wrapper for a product category page
echo '<div class="product-category-wrapper">';
} elseif (is_product()) { // Wrapper for a single product page
echo '<div class="product-wrapper">';
}
}
add_action( 'woocommerce_before_main_content', 'start_wrapper_here', 20 );
모두 다시 닫는 것을 잊지 마십시오. 당신이 실제 톱 페이지 래퍼 (기본값 : <div id="container">
)를 변경하는 wan't 경우
function end_wrapper_here() { // End wrapper
if (is_shop()) {
echo '</div>';
} elseif (is_product_category()) {
echo '</div>';
} elseif (is_product()) {
echo '</div>';
}
}
add_action( 'woocommerce_after_main_content', 'end_wrapper_here', 20 );
, 당신은에 대한 WooCommerce 기능을 편집해야합니다. 이 함수는 일반적으로 get_template_part()
을 사용하여 wrapper-start.php
및 wrapper-end.php
파일을 호출합니다. 이제이 함수를 오버라이드하고 우리 자신의 래퍼를 에코합니다.
function woocommerce_output_content_wrapper() { // Start wrapper for all the page contents
echo '<div class="custom-wrapper">';
}
add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 20 );
function woocommerce_output_content_wrapper_end() { // End wrapper for all the page contents
echo '</div>';
}
add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 20 );
출처
2014-07-21 22:14:02
Tim
wp-content/plugins의 템플릿 파일을 편집하지 마십시오. 그것들은 플러그인을 업데이트 할 때마다 덮어 씌워 질 것입니다. 파일을 복사하여 테마 디렉토리에 붙여 넣고 새 파일을 편집하여 안전하게 작업하십시오. – garvan
@garvan Manish는 당신이 '당신의 커스텀 테마'를 사용해야한다고 암시합니다. – icc97