Skip to:
Content
Pages
Categories
Search
Top
Bottom

Removing default sidebars


  • Roger Coathup
    Participant

    @rogercoathup

    When you create a child theme, the sidebars from the parent bp-sn-theme are included, even if you implement your own functions.php in your child theme.

    Is there anyway to remove these sidebars without resorting to unregister_sidebars function calls in your child functions.php?

    In a similar vein, why isn’t the parent functions.php overridden when you implement a functions.php file in your child theme?

Viewing 8 replies - 1 through 8 (of 8 total)

  • Roger Coathup
    Participant

    @rogercoathup

    Note: unregister_sidebars() doesn’t appear to work.

    Therefore, is there anyway to remove the sidebars registered in bp-sn-parent, without hacking the functions.php file in bp-sn-parent?

    a child theme to the parent theme is not a different structure but a different look… your best shot would be to start over with a theme you like and integrate the functions you need from a bp-sn-theme as example…


    Boone Gorges
    Keymaster

    @boonebgorges

    unregister_sidebar() works but it is weird and finicky.

    WP’s internal documentation says that unregister_sidebar() takes the ID of the sidebar as an argument, which I suppose is technically true, but it’s misleading. Sidebar IDs are automatically generated. They look like sidebar-1, sidebar-2, etc, and are different from the names you give a sidebar when you register it.

    Here’s a little function you can use to see what your sidebars look like (don’t use this on a live site!):

    `function what_are_my_sidebars_called() {

    global $wp_registered_sidebars;

    print “

    "; print_r($wp_registered_sidebars); print "

    “; die();

    }

    add_action( ‘wp_head’, ‘what_are_my_sidebars_called’, 1 );


    Boone Gorges
    Keymaster

    @boonebgorges

    Dang it, those print statements were supposed to have pre tags (to make the print_r readable). You can fill in the blanks.

    I unregistered the sidebars. As mentioned above, they go by ID… not name. Also, if you want to register NEW sidebars… they come first in line. So let’s say you register a new sidebar in your child’s function.php file named “my-sidebar” and want to unregister the other three that the parent theme uses. You have 4 sidebars now to deal with. Your’s (id = sidebar-1) and the other three from the parent. You would do something like this:

    register_sidebars( 1,
    array(
    'name' => 'my-sidebar'
    )
    );

    function remove_sidebar() {
    unregister_sidebar('sidebar-2');
    unregister_sidebar('sidebar-3');
    unregister_sidebar('sidebar-4');
    }
    add_action( 'admin_init', 'remove_sidebar');


    21cdb
    Participant

    @21cdb

    So every time i add a sidebar to my custom theme the id of the bp-default sidebar is count up by 1? That would mean i have to dive back into child-themes function.php and higher the unregister_sideabar(‘sidebar-x’) by one?

    Edit: I checked it in my child-theme and the procedure above is unfortunately true. WordPress Codex also says it only goeas by ID: https://codex.wordpress.org/Function_Reference/unregister_sidebar


    Roger Coathup
    Participant

    @rogercoathup

    Thanks for the feedback guys.

    I adopted David’s function and it worked.


    Roger Coathup
    Participant

    @rogercoathup

    Note: As of BuddyPress 1.2, this is less of an issue, as the default theme (similarly to most WordPress themes) only comes with a single sidebar

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Removing default sidebars’ is closed to new replies.
Skip to toolbar