Knowledge Base

Knowledge base

Explore How-To's and learn best practices from our knowledge base.

Custom widget placement

Modified on: Thu, 30 May, 2019 at 11:44 PM


Custom widget placement




1. Move review widget to the product's tabs

Add the following code to your theme's functions.php:

if (class_exists( 'JudgeMe' )) {    add_action( 'init', 'jgm_remove_review_widget' );     function jgm_remove_review_widget () {        // Remove the default widget placement        remove_action( 'woocommerce_after_single_product_summary', array( 'JGM_Widget', 'judgeme_review_widget' ), 14 );    }      add_filter( 'woocommerce_product_tabs', 'jgm_add_review__widget_to_tab' );      function jgm_add_review__widget_to_tab ($tabs) {         $tabs['judgeme_reviews'] = array(            'title' => __( 'Reviews', 'woocommerce' ),            'priority' => 50,            'callback' => array( 'JGM_Widget', 'judgeme_review_widget' )         );          return $tabs;     } }





Leex theme only

If you use Leex theme and put the widget to inside the tab, you may need additional Javascript, please put this to your theme's js file to reactive the leex widget after showing the review tab (change the review button's class to match your theme code if needed)

if (typeof jdgm !== 'undefined') {  jdgm.$('.judgeme_reviews_tab a').click(function(){    setTimeout(function(){ jdgm.$('.jdgm-rev-widg__reviews').masonry('layout') ;}, 300);  }); }



Did you find it helpful? Yes No Still have questions? Talk to us here

Can you please tell us how we can improve this article?

More articles in Woocommerce