Viewing 1 replies (of 1 total)
  • example only – there will be many more different ways to do this.

    – in functions.php of a child theme, add the necessary code to create a new widget area; example:

    add_action( 'after_setup_theme', 'twentyfifteenchild_setup' );
    
    function twentyfifteenchild_setup() {
    add_action( 'widgets_init', 'twentyfifteenchild_widgets_init' );
    add_filter( 'body_class', 'twentyfifteenchild_body_class' );
    }
    
    //register right sidebar
    function twentyfifteenchild_widgets_init() {
    
    	register_sidebar( array(
    		'name' => __( 'Right Sidebar Widget Area', 'twentyfifteen' ),
    		'id' => 'right',
    		'description'   => __( 'Add widgets here to appear in your right sidebar.', 'twentyfifteen' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h2 class="widget-title">',
    		'after_title'   => '</h2>',
    	) );
    
    }
    
    //body class correction
    function twentyfifteenchild_body_class( $classes ) {
    
    	if ( is_active_sidebar( 'right' ) ) {
          $classes[] = 'two-sidebars';
        }
    	return $classes;
    }

    – (one possibility) at the start of footer.php of the child theme, call a new sidebar (this way the right sidebar is available with all template files); example:

    <?php get_sidebar( 'right' ); ?>

    – create a file sidebar-right.php in the child theme, with this code:

    <?php
    /**
     * The sidebar containing the right widget area - child theme
     *
     * @package WordPress
     * @subpackage Twenty_Fifteen
     * @since Twenty Fifteen 1.0
     */
    
    if ( is_active_sidebar( 'right' )  ) : ?>
    <div id="sidebar-right" class="sidebar-right">
    	<div id="tertiary" class="tertiary">
    
    			<div id="widget-area" class="widget-area" role="complementary">
    				<?php dynamic_sidebar( 'right' ); ?>
    			</div><!-- .widget-area -->
    
    	</div><!-- .tertiary -->
    </div><!-- .sidebar-right -->
    <?php endif; ?>

    – add some corrresponding CSS to style.css of the child theme … possibly with @media queries to adjust the layout to narrow screens.

    full child theme example code: http://www.transformationpowertools.com/wordpress/wp-content/uploads/2015/07/twentyfifteen-ts.zip

Viewing 1 replies (of 1 total)

The topic ‘TwentyFifteen-Right Sidebar’ is closed to new replies.