wordpresswoocommercehook-woocommercereviewwoocommerce-theming

Move Reviews outside of Tabs - Woocommerce


I haven't had any luck with the answers posted here. All I want to do is place woocommerce "reviews" outside of the premade woocommerce tabs (description, reviews, and additional information)

I know how to remove the reviews just fine with

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
    unset( $tabs['reviews'] );      // Removes reviews
    return $tabs;
}

Now I want to add that back out somewhere different (outside of the tab area)


Solution

  • Well it depend on where you want to output it. After you decide where you want to output it then use comments_template() function.

    For example if you want to output it after product summary section, then you could do something like this:

    add_action( 'woocommerce_after_single_product_summary', 'your_theme_review_replacing_reviews_position', 21 );
    
    function your_theme_review_replacing_reviews_position()
    {
      comments_template();
    }
    
    add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
    
    function woo_remove_product_tabs( $tabs )
    {
        unset( $tabs['reviews'] );
    
        return $tabs;
    }
    

    Or you could hook it somewhere else like all the way down the page using woocommerce_after_single_product, like so:

    add_action( 'woocommerce_after_single_product', 'your_theme_review_replacing_reviews_position');
    
    function your_theme_review_replacing_reviews_position()
    {
      comments_template();
    }
    
    add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
    
    function woo_remove_product_tabs( $tabs )
    {
        unset( $tabs['reviews'] );
    
        return $tabs;
    }
    

    Both examples are tested and work. Let me know if you were able to get it to work!