How do i manually place a widget code

Just register another widget area. Don’t take the name sidebar literally, you can use the fields anywhere on your page.

In your theme’s functions.php:

add_action( 'after_setup_theme', 'register_multiple_widget_areas' );

function register_multiple_widget_areas()
{
    register_sidebar(
        array(
        'name'          => 'Sidebar',
        'id'            => 'sidebar',
        'description'   => 'describe the function of the box.'
        )
    );
    register_sidebar(
        array(
        'name'          => 'Header',
        'id'            => 'header-widget',
        'description'   => 'Goes at the top of the page.'
        )
    );
}

And wherever you need the header widget call:

dynamic_sidebar( 'header-widget' );

See also register_sidebar() and dynamic_sidebar().

Leave a Comment