• Hello Everyone,

    I have recently started a website and since I am new to all this I have some difficulties related to WordPress. So my question is:

    How can I move Google Custom Search Widget or any other custom developed code/installed widget (E.G: if I create my own Social Media Icons Widget) to Header area?

    I have checked the Appearance > Widgets sections but there is only option for Sidebar & Footer but not Header to move the widgets.

    Please help me and explain me step by step. I have searched a lot but didn’t sort it out.

    Any help and suggestions would be highly appreciated.

    Thanks a lot in advance.

    Kind Regards.

Viewing 1 replies (of 1 total)
  • Register a sidebar, add this dynamic sidebar callback in your header.php file ( child theme ), and then add widgets:

    Add to your functions file:

    function register_my_sidebar() {
        register_sidebar(array(
            'name' => __( 'header sidebar', 'elegant-light' ),
            'id' => 'header-sidebar',
            'description' => 'Header sidebar',
            'before_widget' => '<aside id="header-sidebar" class="widget %2$s">',
            'after_widget' => '</aside>'
        ));
    }
    
    add_action( 'widgets_init', 'register_my_sidebar' );

    Add to your header.php file this newly created sidebar callback:

    <?php dynamic_sidebar('header-sidebar');?>

    Remember, use child theme.

Viewing 1 replies (of 1 total)
  • The topic ‘How Do I Move Google Custom Search Or Any Widget To Header?’ is closed to new replies.