• Hellohello,

    I am trying to put a extra widget area into the header, but until now I am unsuccesfull.

    I managed to get the extra widget area in the widget section, but you can’t see him on my actual website. I don’t where to put the snippet in my header.php and do I have to add something more.

    I used this code in function.php

    <?php
    /**
    * Register Widget Area.
    *
    */
    function wpgyan_widgets_init() {

    register_sidebar( array(
    ‘name’ => ‘Header Sidebar’,
    ‘id’ => ‘header_sidebar’,
    ‘before_widget’ => ‘<div>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ‘<h2 class=”rounded”>’,
    ‘after_title’ => ‘</h2>’,
    ) );
    }
    add_action( ‘widgets_init’, ‘wpgyan_widgets_init’ );
    ?>

    And I should use this one in header.php

    <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘header_sidebar’) ) :

    endif; ?>

    But whe exactly in header.php should I put this and should I add something to this code?

    Is it also possible to just divide the existing widget area in some kind of way?

    Can someone help me??

    Thank you in advance

    Greetzz, Marleen

Viewing 2 replies - 1 through 2 (of 2 total)
  • You have to put the code where you want…
    I’ve put the code inside nav tag and in my theme I’ve used it to display a translation widget at the right of the header

    <!-- begin nav -->
    <nav>
        <?php wp_nav_menu('theme_location=main-menu&container=&container_class=menu&menu_id=main&menu_class=main-nav sf-menu&link_before=&link_after=&fallback_cb=false'); ?>
        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('header_sidebar') ) :
    
        endif; ?>
    </nav>
    <!-- end nav -->
    Thread Starter L1tje

    (@l1tje)

    Okay, thank constanzomax

    But I still have an additional question. Should I put the code between <div> tags or can I put it into the header like this?

    But I first gonna try it…

    I let you know if I managed it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘extra widget area in header, or divide the widget area that is already there’ is closed to new replies.