Site icon Catch Themes

How to add a widget area directly after the header

Hello again. Came across another issue here - I'm having difficulty adding a working widget area after the catchbase header. I wish to add a revolution slider widget here, but have been unsuccessful in my attempts. So far, I've added a variety of widget areas - none of which add below the header any working widget.
// Adds a widget area.
if (function_exists('register_sidebar')) {
	register_sidebar(array(
	'name' => 'Extra Header Widget Area',
	'id' => 'extra-widget-area',
	'description' => 'Extra widget area after the header',
	'before_widget' => '<div class="widget my-extra-widget">',
	'after_widget' => '</div>',
	'before_title' => '<h2>',
	'after_title' => '</h2>'
	));
}
// Place the widget area after the header in home page only
add_action ('__after_header', 'add_my_widget_area', 10);
function add_my_widget_area() {
  if ( tc__f('__is_home') && function_exists('dynamic_sidebar') ) {
    dynamic_sidebar('Extra Header Widget Area');
  }
}

function my_widgets_init() {

register_sidebar( array(
    'name' => __( 'Main Sidebar', 'your-theme' ),
    'id' => 'sidebar-1',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => "</div>",
    'before_title' => '<h3>',
    'after_title' => '</h3>',
) );

register_sidebar( array(
    'name' => __( 'Header Area', 'your-theme' ),
    'id' => 'sidebar-2',
    'description' => __( 'An optional widget area for your site header', 'your-theme' ),
    'before_widget' => '<div id="%1$s" class="headwidget %2$s">',
    'after_widget' => "</div>",
    'before_title' => '<h3>',
    'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'my_widgets_init' );

// Add a widget.
if (function_exists('register_sidebar')) {
	register_sidebar(array(
	'name' => 'Try This After Header',
	'id' => 'extra-widget',
	'description' => 'After Header',
	'before_widget' => '<div id="%1$s" class="widget %2$s">',
	'after_widget' => '</div>',
	'before_title' => '<h2>',
	'after_title' => '</h2>'
	));
}
// Place the widget after the header
add_filter ('__after_header', 'add_my_widget');
function add_my_widget() {
	if (function_exists('dynamic_sidebar')) {
	dynamic_sidebar('Try This After Header');
	}
}
Any advice? I've also used the 'before post' widget which worked, but showed the slider three times no matter what I tried.
Exit mobile version