Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

New Widget in Header WordPress

  • SOLVED

I need to add a widget area to the header of healthydirections.com.
We would like to be able to use the widget to insert a rotating ad widget.
Thanks so much,
Annette Kalapaca

Answers (4)

2014-01-28

Navjot Singh answers:

Job completed as per requirement.

2014-01-28

Agus Setiawan answers:

hehe, this is not wordpress, but i can help you to add widget on header area,
thanks.

2014-01-28

Arnav Joy answers:

you can use following to register widget

<?php

register_sidebar(array(
'name' => __( 'Header Widget Area' ),
'id' => 'header-widget',
'description' => __( 'Widgets in this area will be shown on the header.' ),
'before_title' => '<h1>',
'after_title' => '</h1>'
));?>


and you can call it as

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

for add rotator you can use following plugin

http://wordpress.org/plugins/adrotate/

2014-01-28

Hariprasad Vijayan answers:

Hello,
Add following code in your function.php

function custom_widgets_init() {
register_sidebar( array(
'name' => __( 'Header Widget Area', 'healthydirections' ),
'id' => 'header-widget',
'description' => 'Appears in Header',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'custom_widgets_init' );

Above code enable new widget area. You can add rotating ad widget in to it from wordpress dashboard.

Add following code to your header where you want to display those widget.


<?php if ( is_active_sidebar( 'header-widget' ) ) : ?>
<div class="header-widget">
<?php dynamic_sidebar( 'header-widget' ); ?>
</div>
<?php endif; ?>

You can change its style as per your need.

Let me know if you need anymore help.
Thanks