Disabling Default Widgets from Admin Panel

After the installation of WordPress on your local server or on your site, it registers some standard widgets with the default theme, specially on the sidebar. However, if you want to upload your own theme (I am assuming you would do that some point), perhaps it might be the best idea to get rid of all the unnecessary widgets that gets added with the default theme automatically.

The following snippet, not only removes the default widgets already added on the default theme but also removes some other widgets upon activating your custom or new theme for your site. This could be really useful for theme developers and custom theme developers. Now, all you need to do is to add this snippet on your custom or new theme’s functions.php file and activate the theme.

add_action( 'widgets_init', 'remove_all_default_widgets' );
function remove_all_default_widgets() {
   unregister_widget('WP_Nav_Menu_Widget'); }

We have unregistered nearly every single possible widgets you can find on a default WP installation. Give it a shot and let me know. Hope you liked it. Thanks.

Source: WordPress Codex.

Today In History



Leave a Reply

Note: Convet HTML, PHP, JavaScripts from HTMLify, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.