반응형
Woocommerce 3에서 관련 제품 제목 이름 변경
Woocommerce에서 Related Products 텍스트로 변경하기 위해 다음과 같은 기능을 가지고 있었습니다.
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Related Books', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
항상 완벽하게 동작했지만 Woocommerce 버전 3.0 이후로는 이 기능은 더 이상 작동하지 않습니다.
버전 3.0 이상에서 동작시키려면 어떻게 수정해야 합니까?
이거 먹어봐, 나랑 잘 돼
add_filter( 'gettext', 'wps_translate_words_array' );
add_filter( 'ngettext', 'wps_translate_words_array' );
function wps_translate_words_array( $translated ) {
$words = array(
// 'word to translate' = > 'translation'
'Related Products' => 'Check out these related products',
);
$translated = str_ireplace( array_keys($words), $words, $translated );
return $translated;
}
이제 그것에 대한 필터가 있다.이름은 "woocommerce_product_related_products_heading"입니다.
그래서 당신은 당신의 테마 함수에 작은 조각들을 추가할 수 있습니다.다음과 같은 php 파일:
add_filter('woocommerce_product_related_products_heading',function(){
return 'My Custom nice related title';
});
간단한 대체 방법
템플릿 파일의 테마를 통해 Woocommerce 템플릿을 덮어씁니다. 여기서 직접 이름을 변경할 수 있습니다.
<h2><?php esc_html_e( 'Related products', 'woocommerce' ); ?></h2>
수신인:
<h2><?php esc_html_e( 'Related Books', 'woocommerce' ); ?></h2>
언급URL : https://stackoverflow.com/questions/45688753/rename-related-products-title-in-woocommerce-3
반응형
'programing' 카테고리의 다른 글
토큰을 쿠키, 로컬 스토리지 또는 세션에 저장해야 합니까? (0) | 2023.03.04 |
---|---|
플랫 번들링이란 무엇이며 롤업이 웹팩보다 나은 이유는 무엇입니까? (0) | 2023.03.04 |
크로스 오리진(CORS) 오류 검출 방법Javascript의 XMLHttpRequest()에 대한 기타 오류 유형 (0) | 2023.03.04 |
클릭 시 중첩된 React 구성 요소에서 이벤트가 버블링되는 것을 방지하려면 어떻게 해야 합니까? (0) | 2023.03.04 |
Oracle SQL의 테이블에 대한 모든 제약 조건 이름 표시 (0) | 2023.03.04 |