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
Agus Setiawan answers:
hehe, this is not wordpress, but i can help you to add widget on header area,
thanks.
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/
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