Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: I would add a fourth-section, but the widgets?

I’m not sure why there were br tags outside the quote marks in the code above. That’s HTML, not PHP. This is the code I’m using in my child functions.php file (below). It works. It’s for the BP 1.2 theme (which only has one sidebar). So I’m basically just creating two new sidebar areas (Member and Public) and then unregistering the default sidebar from the parent theme (which again… is the BP 1.2 default theme).

<?php

/* Register Sidebars */
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Public',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
));
register_sidebar(array(
'name' => 'Member',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
));
}

/* Unregister Parent Sidebar */
function remove_sidebar() {
unregister_sidebar('sidebar-3');
}
add_action( 'admin_init', 'remove_sidebar');

?>

To display these widget areas in your pages, just add this where ever you want in your templates (most likely in the sidebar.php file).

<?php if ( !dynamic_sidebar( 'Public' ) ) : endif; ?>
<?php if ( !dynamic_sidebar( 'Member' ) ) : endif; ?>

Of course… I also have this wrapped with if (is_user_logged_in()) since in my case, I want a different sidebar for logged in users vs. logged out users. Just modify the above for your needs.

Skip to toolbar