[Zerif Lite] Remove Zerif Widgets from Admin Panel
-
Hello Support,
I want remove unneeded widget clutter from my Zerif Child Theme. As per WordPress manual, this code used in my child’s functions.php should do the trick, but it does not – The Zerif Widgets and Widget Areas still show up in the admin panel:
Someone please provide assistance how to get rid of the Zerif Lite Widgets and Widget areas, so they do not show up in admin panel anymore.
function kill_zerif_widgets(){ unregister_sidebar('zerif_ourfocus'); unregister_sidebar('zerif_testimonial_widget'); unregister_sidebar('zerif_clients_widget'); unregister_sidebar('zerif_team_widget'); } add_action( 'widgets_init', 'kill_zerif_widgets', 11 );Here’s my complete child functions.php, in case someone needs to see it to identify and solve the problem:
<?php // Child Theme Loader (Loads functions.php from Zerif-Lite) add_action( 'wp_enqueue_scripts', 'child_enqueue_styles',99); function child_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style',get_stylesheet_directory_uri() . '/custom.css', array( $parent_style )); } if ( get_stylesheet() !== get_template() ) { add_filter( 'pre_update_option_theme_mods_' . get_stylesheet(), function ( $value, $old_value ) { update_option( 'theme_mods_' . get_template(), $value ); return $old_value; // prevent update to child theme mods }, 10, 2 ); add_filter( 'pre_option_theme_mods_' . get_stylesheet(), function ( $default ) { return get_option( 'theme_mods_' . get_template(), $default ); } ); } /** * Unregister some of the Zerif sidebars * This code doesnt work. Zerif widgets still there */ function kill_zerif_widgets() { unregister_sidebar('zerif_ourfocus'); unregister_sidebar('zerif_testimonial_widget'); unregister_sidebar('zerif_clients_widget'); unregister_sidebar('zerif_team_widget'); } add_action( 'widgets_init', 'kill_zerif_widgets', 22 ); /** * Register my own content areas. * This code works as inteded, new widgets show up in WP-Admin */ function ftk_contentwidgets_init() { register_sidebar(array( 'name'=> 'Fortek Title/Header', 'id' => 'ftk_title', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); register_sidebar(array( 'name'=> 'Fortek Products & Services', 'id' => 'ftk_focus', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); register_sidebar(array( 'name'=> 'Fortek About Us', 'id' => 'ftk_aboutus', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); register_sidebar(array( 'name'=> 'Fortek Team', 'id' => 'ftk_team', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); register_sidebar(array( 'name'=> 'Fortek Contact', 'id' => 'ftk_contact', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); register_sidebar(array( 'name'=> 'Fortek Ribbon', 'id' => 'ftk_ribbon', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); register_sidebar(array( 'name'=> 'Fortek News', 'id' => 'ftk_news', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', )); } add_action( 'widgets_init', 'ftk_contentwidgets_init' ); ?>
-
Hello,
I have was able to remove a portion of the widgets by using this code:
add_action( 'after_setup_theme', 'kill_zerif_widgets', 11 ); function kill_zerif_widgets(){ remove_action( 'widgets_init', 'zerif_widgets_init' ); }However, that removes only the standard widget areas like footer widgets or search. How do I need to modify the above code, so it removes the following widgets and widget areas:
Zerif – Clients widget
Zerif – Our focus widget
Zerif – Team member widget
Zerif – Testimonial widgetThe solution is so easy actually. Just wondering why no one here was able to help me, as it turns the out the problem is very simple. I missed only 1 line of code to resolve the problem.
This works flawless:
add_action( 'after_setup_theme', 'kill_zerif_widgets', 11 ); function kill_zerif_widgets(){ remove_action( 'widgets_init', 'zerif_widgets_init' ); remove_action( 'widgets_init', 'zerif_register_widgets' ); }Topic resolved and closed.
The topic ‘[Zerif Lite] Remove Zerif Widgets from Admin Panel’ is closed to new replies.