Here, I tried to show how to override WooCommerce Price Filter widget.
At first Add this below code to your functions.php file. copy the class-wc-widget-price-filter.php file from wp-content\plugins\woocommerce\includes\widgets to your theme file and include that by
include_once or include get_template_directory()
/*-------------------------------
Override woocommerce product categories widgets
---------------------------------*/
add_action( 'widgets_init', 'override_woocommerce_widgets', 15 );
function override_woocommerce_widgets() {
// Ensure our parent class exists to avoid fatal error
if ( class_exists( 'WC_Widget_Price_Filter' ) ) {
unregister_widget( 'WC_Widget_Price_Filter' );
include_once( 'inc/custom-widgets/fengo-class-wc-widget-price-filter.php' );
//or
//include get_template_directory() . '/inc/custom-widgets/fengo-class-wc-widget-price-filter.php';
register_widget( 'Fengo_WC_Widget_Price_Filter' );
}
}
At first Add this below code to your functions.php file. copy the class-wc-widget-price-filter.php file from wp-content\plugins\woocommerce\includes\widgets to your theme file and include that by
include_once or include get_template_directory()
/*-------------------------------
Override woocommerce product categories widgets
---------------------------------*/
add_action( 'widgets_init', 'override_woocommerce_widgets', 15 );
function override_woocommerce_widgets() {
// Ensure our parent class exists to avoid fatal error
if ( class_exists( 'WC_Widget_Price_Filter' ) ) {
unregister_widget( 'WC_Widget_Price_Filter' );
include_once( 'inc/custom-widgets/fengo-class-wc-widget-price-filter.php' );
//or
//include get_template_directory() . '/inc/custom-widgets/fengo-class-wc-widget-price-filter.php';
register_widget( 'Fengo_WC_Widget_Price_Filter' );
}
}
Thank you for sharing excellent information. Your website is very cool. Fully useful your blog post... Online shopping site for women's clothing in india
ReplyDeleteAwesome tutorial!!! Worked like a charm.
ReplyDeleteWorked perfectly - thank you
ReplyDeleteThis comment has been removed by the author.
ReplyDelete