Problems after creating new widget area (2 posts)

  1. ansrikanth
    Posted 3 years ago #


    I'm actually setting up a new menu above the logo and header banner. I'm using the jQuery mega menu for this purpose.

    I have registered the nav menu in functions.php as :

    register_nav_menus( array(
    'primary' => __( 'Primary Navigation', 'gonzo' ),
    'mobile' => __( 'Mobile Navigation', 'gonzo' ),
    'header banner' => __( 'Header Banner Menu', 'gonzo' )
    ) );

    I have also called the widget in the Header.php using :

    <div id="header-widgets">
    <?php dynamic_sidebar('header-widgets'); ?>
    <?php if ( ! dynamic_sidebar( 'Header Banner' ) ) : endif; ?>

    I have added this in the functions.php:

    if (function_exists('register_sidebar')) {
    'id' => 'header-widgets',
    'name' => 'Header widgets',
    'description' => 'Widget area below the header',
    'before_widget' => '<div id="%1$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4>',
    'after_title' => '</h4>'

    The problem is, when I add all of this code, the sidebar disappears and only nav menu shows, and when and when I remove the entire code the nav menu disappears and the sidebar retains. Please Help!

    There is some problem in the functions.php code. Could someone please help me out?!

  2. s_ha_dum
    Posted 3 years ago #

    I think you are confusing menus with dynamic sidebars. It looks like you have registered a menu named 'header banner' and are trying to use it like a dynamic sidebar. They are very different things.

    Also, case matters. You have 'header banner' when you create the menu but 'Header Banner' when you appear to be trying to check for it.

    Also also, spaces can be problematic. I wouldn't register anything as 'header banner'. Use 'header_banner' instead.

Topic Closed

This topic has been closed to new replies.

About this Topic