jeudi 29 janvier 2015

Extra sidebar in Twenty fifteen


I really like the Twenty Fifteen theme, but I need an extra sidebar, preferably on the right side of the screen. I already made a child theme, and tried the following:


Added the following to functions.php



function twentyfifteen_widgets_init2() {
register_sidebar( array(
'name' => __( 'Widget Area Right', 'twentyfifteen' ),
'id' => 'sidebar-2',
'description' => __( 'Add widgets here to appear in your sidebar.', 'twentyfifteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'twentyfifteen_widgets_init2' );'


After that I copied sidebar.php from the parent theme, and added the following to it:



<div id="rightsidebar" class="sidebar">
<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
<div id="widget-area" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div><!-- .widget-area -->
<?php endif; ?>


Now there is an extra sibar visible, but it isn't aligned right. I tried to get it to the right side of the page, but even when I use an absolute position, it still won't go all the way to the right.


Anyone know how to position this second sidebar on the right, without breaking the entire layout for the rest of the site?





Aucun commentaire:

Enregistrer un commentaire