Skip to content

Instantly share code, notes, and snippets.

@baczoni
Created April 24, 2012 15:45
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 baczoni/2480866 to your computer and use it in GitHub Desktop.
Save baczoni/2480866 to your computer and use it in GitHub Desktop.
Wordpress: Create widget areas
//Create widget areas
<?php
// In functions.php
register_sidebar(array(
'name' => 'Sidebar',
'id' => 'sidebar',
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
register_sidebar(array(
'name' => 'Footer',
'id' => 'footer',
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
// In sidebar.php
if ( is_sidebar_active('sidebar') ) {
dynamic_sidebar('sidebar');
}
// In footer.php
if ( is_sidebar_active('footer') ) {
dynamic_sidebar('footer');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment