Forums

Remove Default Widgets (8 posts)

  1. vintres
    Member
    Posted 2 years ago #

    Hi there,

    I am trying to get rid of some of the default widgets that come with my theme ...like on the sidebar. I found the following code:

    add_action( 'widgets_init', 'my_unregister_widgets' );
    
    function my_unregister_widgets() {
    	unregister_widget( 'WP_Widget_Pages' );
    	unregister_widget( 'WP_Widget_Calendar' );
    	unregister_widget( 'WP_Widget_Archives' );
    	unregister_widget( 'WP_Widget_Links' );
    	unregister_widget( 'WP_Widget_Categories' );
    	unregister_widget( 'WP_Widget_Recent_Posts' );
    	unregister_widget( 'WP_Widget_Search' );
    	unregister_widget( 'WP_Widget_Tag_Cloud' );
    }

    But I have no clue what to do it? Should I insert it to my functions.php and if yes, where exactly? Do I have add any code or opening tags for php , etc?

    Sorry to ask these types of question. I have no php background, just trying to desperately put up my blog.

    regards
    thanks,

    Vicnent

  2. jwalin
    Member
    Posted 2 years ago #

    If you want to delete that widget then remove above code from funtions.php otherwise keep it as in same file.

    Jwalin

  3. vintres
    Member
    Posted 2 years ago #

    sorry, what do I have to do?

    I want to get rid of the default widgets, and that is why I read somewhere to INSERT that code, but I have no clue as to where and how?

    any help is appreciated, thanks!

    regards
    Vincent

  4. jwalin
    Member
    Posted 2 years ago #

    for that you have to remove that code nothing else

  5. ecvis17
    Member
    Posted 1 year ago #

    @vintres or anyone

    I am using a sandbox theme and have a same wish/problem. I would like to know how to remove default widgets from the sidebar. I taught it can be done via backend edit widgets tool but it seem it cannot. There is nothing to drag out from the sidebar containers.

    I also tried to find those lines within the /wp-content/themes/sandbox/functions.php
    but they don't seem to e there. Does anyone know the way to remove these?

    Here is the actuall PHP file

    Thank you very much.

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    well, do you just want them gone? Thing is, if you plan to use the sidebar for your own widgets most sidebars are set up to display default widgets, but as soon as you put your own widget in there, the default ones go away

  7. ecvis17
    Member
    Posted 1 year ago #

    @Rev. Voodoo

    Thank you. It Kind of works, but only if I put one new widget in each sidebar container.
    If I just put one then one default widget remains.
    It seems that some of the default widgets correspond to on SIdebar1 and some to Sidebar2.

    What is funny is that I would think that the SIdebar2 would be on the other side not within the same column?!

    And finally what if don't want any widgets, how do I remove the default ones then?
    The only way I can think of is to #some_selector {display:none;} which is an ugly way I believe.

    Thank you

  8. ecvis17
    Member
    Posted 1 year ago #

    @ forget about the last post.
    I found the sidebar.php where is the html of these. So it is enough to comment them out. :) A bit better then the css way. But still.
    The space occupied by the sidebar itself remains even when empty.
    I would expect it to dynamically disappear when empty.

    But that might be the thing of the Theme ...

    Bye

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.