Add Widget Area in template

Posted in: Newspaper
Post count: 17

Hi!
How could I add a widget area in the template?
For exemple : I’d like to transform Header Ads in Widget area,
which file should I edit? What code do I need?
Thanks

Post count: 17

I have add this code in functions.php

register_sidebar(array(
    'name'=>'Header Widget',
    'id' => 'td-header-widget',
    'before_widget' => '<div id="td-header-widget">',
    'after_widget' => '</div>',
    'before_title' => '<div class="block-title"><span>',
    'after_title' => '</span></div>'
));

And I add thic code in header.php

    default:
        // this is the default header configuration
        // (logo + ad) + menu
        locate_template('parts/header-style-1.php', true);
		if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("td-header-widget") ) :
		endif;
        locate_template('parts/menu-header.php', true);
		break;

it works, but is it like that I should do?

Post count: 17

I have found :
In the file parts/header-style-1.php :

            <div class="span8" id="td-header-widget">
            	<?php
					// Header Widget
					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("td-header-widget") ) :
					endif;
				?>
            </div>
            <div class="span8">
                <?php
                    // show the header ad spot
                    echo td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'header'));
                ?>
            </div>
Post count: 3343

Hi,
Great, is everything ok now?

Thanks for the message!

Post count: 5

thanks!

  • This reply was modified 12 years by Gillbergh.
Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Newspaper’ is closed to new topics and replies.