복붙노트

[WORDPRESS] WooCommerce 제품 설명을 추가 지정 콘텐츠

WORDPRESS

WooCommerce 제품 설명을 추가 지정 콘텐츠

해결법


  1. 1.이 방법 후크 the_content 필터에 중독이 사용자 정의 기능을 사용할 수 있습니다 :

    이 방법 후크 the_content 필터에 중독이 사용자 정의 기능을 사용할 수 있습니다 :

    add_filter( 'the_content', 'customizing_woocommerce_description' );
    function customizing_woocommerce_description( $content ) {
    
        // Only for single product pages (woocommerce)
        if ( is_product() ) {
    
            // The custom content
            $custom_content = '<p class="custom-content">' . __("This is the last line in the description", "woocommerce").'</p>';
    
            // Inserting the custom content at the end
            $content .= $custom_content;
        }
        return $content;
    }
    

    코드 functions.php의 활성 자식 테마의 파일 (또는 활성 테마)에 간다. 테스트 및 작동합니다.

    추가 - 포스 제품 설명을 할 때 (당신이 원하는 경우이 사용자 정의 텍스트가 표시되는) 비어 있습니다 :

    add_filter( 'woocommerce_product_tabs', 'force_description_product_tabs' );
    function force_description_product_tabs( $tabs ) {
    
        $tabs['description'] = array(
            'title'    => __( 'Description', 'woocommerce' ),
            'priority' => 10,
            'callback' => 'woocommerce_product_description_tab',
        );
    
        return $tabs;
    }
    

    코드는 Active Child 테마 (또는 활성 테마)의 function.php 파일입니다. 테스트하고 작동합니다.

  2. from https://stackoverflow.com/questions/45577599/add-custom-content-to-woocommerce-product-description by cc-by-sa and MIT license