Remove default WordPress widgets

Community Forums Forums General Discussion Remove default WordPress widgets

This topic is: resolved

This topic contains 6 replies, has 3 voices, and was last updated by  Len 5 months, 2 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #90110

    dogstalkpoetry
    Member
    Post count: 16

    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’ );

    #90111

    Davinder Singh Kainth
    Participant
    Post count: 1198
    #90115

    dogstalkpoetry
    Member
    Post count: 16

    Thanks 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.

    #90244

    Davinder Singh Kainth
    Participant
    Post count: 1198

    Ohk, I have tweeted about the problem. Someone should pitch in.


    Need website customization services or other Genesis / WordPress help ?
    Davinder @ Design Studio iGuiding Media | My Blog | Fresh Genesis Themes Collection

    #90248

    Len
    Participant
    Post count: 22

    Hi 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
    /uploads

    Add 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.


    #90461

    dogstalkpoetry
    Member
    Post count: 16

    Both 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! ;)

    #90499

    Len
    Participant
    Post count: 22

    Hi 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. :)


Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.