在Woocommerce上合并描述和评论选项卡

时间:2019-10-21 08:41:00

标签: php wordpress woocommerce

我尝试合并Woocommerce上的Description和Review选项卡。评论应在说明下方

add_filter( 'woocommerce_product_tabs', 'exetera_custom_product_tabs', 98 );
function exetera_custom_product_tabs( $tabs ) {
    // Custom description callback.
    $tabs['description']['callback'] = function() {
        global $post, $product;


        // Display the content of the Description tab.
        the_content();


        // Display the heading and content of the Additional Information tab.

        echo '<h2>Opinie</h2>';

        do_action( 'woocommerce_product_review_list_args', $product );
    };

    // Remove the additional information tab.
    unset( $tabs['reviews'] );

    return $tabs;
}

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我的建议是这样

add_filter( 'woocommerce_product_tabs', 'exetera_custom_product_tabs', 98 );
function exetera_custom_product_tabs( $tabs ) {

    // Custom description callback.
    $tabs['description']['callback'] = function() {
        global $post, $product;


        // Display the content of the Description tab.
        the_content();


        // Display the heading and content of the Additional Information tab.
        echo '<h2>Opinie</h2>';

        wc_get_template( 'single-product-reviews.php' );

    };

    // Remove the additional information tab.
    unset( $tabs['reviews'] );

    return $tabs;
}