Skip to content

Commit

Permalink
Add homepage-only sidebar widget area, see #23.
Browse files Browse the repository at this point in the history
  • Loading branch information
lancewillett committed Apr 18, 2012
1 parent d1a77cd commit 1e238bf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions source/functions/functions.php
Expand Up @@ -239,6 +239,16 @@ function twentytwelve_widgets_init() {
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );

register_sidebar( array(
'name' => __( 'Homepage Sidebar', 'twentytwelve' ),
'id' => 'sidebar-home',
'description' => __( 'The sidebar for the optional Homepage Template (only shows on homepage)', 'twentyeleven' ),

This comment has been minimized.

Copy link
@lancewillett

lancewillett Apr 21, 2012

Author Contributor

Good eye! Fixed.

'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'twentytwelve_widgets_init' );

Expand Down
3 changes: 2 additions & 1 deletion source/templates/pages/homepage.php
@@ -1,6 +1,6 @@
<?php
/*
Template Name: Home
Template Name: Homepage
*/

get_header(); ?>
Expand All @@ -27,4 +27,5 @@
</div><!-- #content -->
</div><!-- #primary -->

<?php get_sidebar( 'home' ); ?>
<?php get_footer(); ?>
17 changes: 17 additions & 0 deletions source/templates/sidebar-home.php
@@ -0,0 +1,17 @@
<?php
/**
* The Sidebar containing the homepage widget area.
*
* If no active widgets in this sidebar, it will be hidden completely.
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/
?>

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

0 comments on commit 1e238bf

Please sign in to comment.