Skip to content

Instantly share code, notes, and snippets.

@sarvar
Created November 18, 2016 07:11
Show Gist options
  • Save sarvar/0038371c66dc7c52886df43e736a6a3a to your computer and use it in GitHub Desktop.
Save sarvar/0038371c66dc7c52886df43e736a6a3a to your computer and use it in GitHub Desktop.
Adding widget to Wordpress
in functions.php:
//add a widget area in the header as described by TomHart
if ( function_exists ('register_sidebar') )
register_sidebar( array(
'name' => __( 'Header Widgets Area', 'twentythirteen' ),
'id' => 'sidebar-header',
'description' => __( 'Header widgets area for my child theme.' , 'twentythirteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
in header.php:
<?php if ( !function_exists('dynamic_sidebar') ||
!dynamic_sidebar('Header Widgets Area') ) :
endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment