Skip to content

Instantly share code, notes, and snippets.

@marcosnakamine
Last active March 21, 2017 20:02
Show Gist options
  • Save marcosnakamine/e50d0e160d75ee0cfeb407b6d5e0a268 to your computer and use it in GitHub Desktop.
Save marcosnakamine/e50d0e160d75ee0cfeb407b6d5e0a268 to your computer and use it in GitHub Desktop.
WordPress - Add dynamic sidebar
<?php
add_action( 'init', 'theme_widgets_init' );
function theme_widgets_init() {
register_sidebar( array (
'name' => 'Widget',
'id' => 'primary_widget_area',
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => "</div>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
<?php dynamic_sidebar('primary_widget_area'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment