How to add Top Right Widget in Twenty Twelve WP Theme

These Adverts help to pay for this site. ai2

To add an extra widget area at the top right of the header are of the WordPress Twenty Twelve Theme, follow these steps.


These Adverts help to pay for this site ai6.

Add this to a functions.php file in the child theme

//add a widget area in the header
if ( function_exists (‘register_sidebar’) )
register_sidebar( array(
‘name’ => __( ‘Header Widgets Area’, ‘twentytwelve’ ),
‘id’ => ‘sidebar-header’,
‘description’ => __( ‘A new header widgets area for my child them’ , ‘twentytwelve’ ),
‘before_widget’ => ‘
<aside class=”widget %2$s” id=”%1$s”>’,
‘after_widget’ =&gt; ‘</aside>’,
‘before_title’ =&gt; ‘
<h3 class=”widget-title”>’,
‘after_title’ =&gt; ‘</h3>
‘,
) );
add_action( ‘widgets_init’, ‘twentytwelve_widgets_init’ );

Create new file called sidebar-header.php
and add this code

<!–?php if ( is_active_sidebar( ‘sidebar-header’ ) ) : ?–>
<div id=”headWidgets” role=”complementary”></div>
<!–?php endif; ?–>

In the child theme add the following to the header.php file.
If the child theme does NOT have a header.php, copy this from the main theme, and then add the line where you want it to appear.


Agoda HolidaysAgoda HolidaysThese Adverts help to pay for this site. ai5

<!–?php get_sidebar( ‘header’ ); ?–>

Add the following code in style.css to right align this new widget

#headWidgets{
position: relative;
margin-top: -135px;
float: right;
margin-right: 10px;
}

 


43.1 - 585,722
DreamHost

Scroll down for Comments
0 0 votes
Article Rating
Subscribe
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments