Skip to content

Instantly share code, notes, and snippets.

@morktron
Created May 7, 2013 01:22
Show Gist options
  • Save morktron/5529635 to your computer and use it in GitHub Desktop.
Save morktron/5529635 to your computer and use it in GitHub Desktop.
Add new widget areas to a Wordpress theme, then you must add some code to files where you want the widget or add them here via 'hooks'
<?php
function register_widget_area() {
add_action( 'widgets_init', 'register_widget_area' );
// Hero widget area
if( function_exists( 'register_sidebar' ) ) {
register_sidebar( array(
'name' => 'Hero Widget',
'id' => 'hero_widget',
'description' => "Hero widget description in admin",
'before_widget' => '<aside class="hero">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="title">',
'after_title' => '</h1>',
) );
}
// Top Contact widget area
if( function_exists( 'register_sidebar' ) ) {
register_sidebar( array(
'name' => 'Top Contact',
'id' => 'top_contact',
'description' => "Top Contact widget displayed on all pages",
'before_widget' => '<aside class="top-contact">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="title">',
'after_title' => '</h1>',
) );
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment