Organizational Research By

Surprising Reserch Topic

how to add widget to the header php in wordpress


how to add widget to the header php in wordpress  using -'wordpress,wordpress-plugin'

i have installled a pludgin whose named is Translator Box , i using its short code and put it into my wordpress theme header.php.

 [translation_box languages="english,russian,german,spanish,french,chinese" width="100%" height="200px" bgcolor="white" txtcolor="#000000"]


but is doesn't work!

it also generate a widget at Enabled widget in the widgets part. is there a way when using some code in header.php that can invoke the widget? thank you.
    

asked Oct 13, 2015 by amit.gupta
0 votes
2 views



Related Hot Questions

1 Answer

0 votes

You can define a part in your header.php to show widgets. In your functions.php make something like this:

function my_widgets_init() {

register_sidebar( array(
    'name' => __( 'Main Sidebar', 'your-theme' ),
    'id' => 'sidebar-1',
    'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Header Area', 'your-theme' ), 'id' => 'sidebar-2', 'description' => __( 'An optional widget area for your site header', 'your-theme' ), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'my_widgets_init' );

The first part for example will be your widget area in the sidebar and the second your widget area in your header.

Now include in your header.php where your widget should be.

In your admin interface you should now have 2 areas ('Main Sidebar' and 'Header Area') you can fill with widgets.

answered Oct 13, 2015 by suyesh.lokhande

...