Easily add widget areas to theme / template like Blogger (blogspot)
-
Okay, I recently switched from Blogger to WordPress and have been trying to get a widget under my header for almost a week now, and still can not find a theme (even Thesis!) that will work.
I don’t understand why WordPress doesn’t just have a customizable widget layout like blogger (blogspot): http://4.bp.blogspot.com/-G2jbh9WhLso/TpG3OBwFVHI/AAAAAAAAAQM/AEgIGIMVZg4/s1600/Four+Collumn+Template.JPG
I mean, it’s seems such an obvious feature that everyone would need. All i really need is to add a image under the header and under the tabs like i had on my original blogspot blog:
http://iosmusician.blogspot.com/I’ve tried dozens to add custom code to dozens of themes that claim to do this, but nothing has worked so far…
thanks,
-Sean
-
Ok,
There are many themes with different sidebar and widget layouts out there, this gives WordPress theme designers the ability to create and control the way they want the theme to show.It might be that the theme you like does not have the widget areas you want, so the options are to change the theme, or get “under the hood!”
An extra Widget Area can be done really easy, a little code in functions.php, a new template part file and a modification to the template file or header.php
If you have a spare widget area that you know you will not be using, wrap it in a template part and call it in the template.
What theme do you have installed?
Based on a Twenty Eleven Child Theme
Adding a new Widget Area, wrapping it in a Template Part, and calling the filefunctions.php
add_action( 'after_setup_theme', 'child_theme_setup' ); if ( !function_exists( 'child_theme_setup' ) ): function child_theme_setup() { register_sidebar( array( 'name' => __( 'Horizontal Widget Area One', 'twentyeleven' ), 'id' => 'horizontal-1', 'description' => __( 'An optional horizontal widget area', 'twentyeleven' ), ) ); } endif;
The Template Part:
A new file horizontal-1.php<?php if ( is_active_sidebar( 'horizontal-1' ) ) : ?> <div class="widget-area horizontal-1" role="complementary"> <?php dynamic_sidebar( 'horizontal-1' ); ?> </div><!-- .widget-area --> <?php endif; ?>
Then copy the page or header.php from the parent to the child theme
and where you want the the new widget area to show.<?php get_template_part('horizontal','1'); ?>
Adding the class horizontal-1 means you can style it in style.css
.horizontal-1 { list-style: none; text-align: center; }
HTH
David
THANK YOU!!!!!!!!!!!
Just marked the topic as resolved
- The topic ‘Easily add widget areas to theme / template like Blogger (blogspot)’ is closed to new replies.