Community Forums › Forums › Archived Forums › General Discussion › Remove default WordPress widgets
Tagged: #unregisterwidget #prose
- This topic has 6 replies, 3 voices, and was last updated 10 years, 10 months ago by Len.
-
AuthorPosts
-
February 13, 2014 at 5:56 am #90110Eva LimMember
Hi I'm trying to remove the default Calendar widget from the Appearance>Widgets page on Prose theme.
I've tried the code below (with and without a priority number) but it doesn't work. Any idea why? Thanks.//* Remove default widget from WP
function remove_calendar_widget() {
unregister_widget('WP_Widget_Calendar');
}
add_action( 'widgets_init', 'remove_calendar_widget' );February 13, 2014 at 6:29 am #90111Davinder Singh KainthMemberFebruary 13, 2014 at 6:53 am #90115Eva LimMemberThanks for the quick response and links. I actually got my code from those two exact articles. But it's not working for some reason I can't figure out.
February 14, 2014 at 12:50 am #90244Davinder Singh KainthMemberOhk, I have tweeted about the problem. Someone should pitch in.
Sunshine PRO genesis theme
Need Genesis help? Davinder @ iGuiding Media | My Blog | Fresh Genesis ThemesFebruary 14, 2014 at 3:20 am #90248LenParticipantHi dogstalkpoetry.
I'm not really up on the Prose theme because I've rarely used it but I think it has something to do with the fact it uses a special page for inputting custom php.
I would just make a plugin out of it. Add this to the site's plugin folder ...
<?php /* Plugin Name: Remove Calendar Widget Plugin URI: http://YourSite.com Description: Removes WordPress calendar widget from widgets page Author: Your Name Author URL: http://YourSite.com Version: 1.0 */ function remove_default_widgets() { unregister_widget('WP_Widget_Calendar'); } add_action('widgets_init', 'remove_default_widgets', 11);
... and name it something descriptive like remove-calendar-widget.php
When you activate it the widget should be gone.
An alternative is to make it a MU Plugin. (must use plugin)
Create a folder in the wp-content directory called mu-plugins. So the wp-content directory should now look like this ...
/wp-content
/mu-plugins
/plugins
/themes
/upgrade
/uploadsAdd the plugin file from above to the mu-plugins folder. The advantage to this method is your new plugin doesn't have to be manually activated - it is automatically activated. It can only be deactivated by deleting the file. It's kind of foolproof if your dealing with clients.
Let us know if it works for you.
February 15, 2014 at 5:32 am #90461Eva LimMemberBoth methods work perfectly. The 2nd method works only if the file is saved directly inside the mu-plugin folder (ie. no subdirectories.)
Thanks guys. It's my first time creating a plugin! 😉
February 15, 2014 at 11:44 am #90499LenParticipantHi dogstalkpoetry.
The 2nd method works only if the file is saved directly inside the mu-plugin folder (ie. no subdirectories.)
Yep. That's why I said "Add the plugin file from above to the mu-plugins folder." Perhaps I should have clarified further but glad to see you have it working. 🙂
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.