22 Nov 2016

Adding widget areas using functions.php

The following code inserted into your child themes functions.php file will create two new widget areas called banner and dropmenu:

/**
* Register our sidebars and widgetized areas.
*
*/
function arphabet_widgets_init() {

register_sidebar( array(
'name' => 'banner',
'id' => 'banner',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );



register_sidebar( array(
'name' => 'dropmenu',
'id' => 'dropmenu',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );

}

add_action( 'widgets_init', 'arphabet_widgets_init' );

 

Create a hook in your theme by using the following: 

<?php dynamic_sidebar( 'dropmenu' ); ?>