Skip to content

Instantly share code, notes, and snippets.

@shazdeh
Created November 8, 2013 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shazdeh/7367465 to your computer and use it in GitHub Desktop.
Save shazdeh/7367465 to your computer and use it in GitHub Desktop.
Content widget areas. Registers two widget areas that are displayed above and below the main content area.
<?php
add_action( 'widgets_init', 'register_content_widget_areas' );
add_action( 'themify_content_start', 'display_content_top_area' );
add_action( 'themify_content_end', 'display_content_bottom_area' );
function register_content_widget_areas() {
register_sidebar(array(
'name' => __( 'Content Top' ),
'id' => 'content-top',
'description' => __( 'Displays the widgets above the content area.' ),
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
));
register_sidebar(array(
'name' => __( 'Content Bottom' ),
'id' => 'content-bottom',
'description' => __( 'Displays the widgets below the content area.' ),
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
));
}
function display_content_top_area() {
if( is_active_sidebar( 'content-top' ) ) {
echo '<div class="content-top" id="content-top">';
dynamic_sidebar( 'content-top' );
echo '</div>';
}
}
function display_content_bottom_area() {
if( is_active_sidebar( 'content-bottom' ) ) {
echo '<div class="content-bottom" id="content-bottom">';
dynamic_sidebar( 'content-bottom' );
echo '</div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment