Widget in Header area
-
I would like to add a widget in the header area but I don’t seem to be having a lot of success. I would like to put 4 small icons/png’s to the far right side.
I am using a child Theme with Storefront. I have gathered I need to add widget to the widgets section and than add it to the headers.php file.
It seems all the advice I have found is specific to other Themes. How would I go about doing this ?
Thanks!
-
So I figured this out. There were three steps:
1. Add to to my functions.php in my storefront-child-theme:
‘ function storefront_child_widgets_init() {
register_sidebar( array(
‘name’ => ‘Topmost Widget’,
‘id’ => ‘topmost-widget’,
‘description’ => ”,
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h1 class=”widget-title”>’,
‘after_title’ => ‘</h1>’,
) );
}add_action( ‘widgets_init’, ‘storefront_child_widgets_init’ );
function storefront_child_social_icons() {
dynamic_sidebar( ‘topmost-widget’ );
}add_action( ‘storefront_header’, ‘storefront_child_social_icons’, 40 );
‘
2. Add (in my case) a text Widget to the newly created topmost widget area in Appearances>Widgets:
<img src = your-file.png>3. Add the following to my style.css file:
(I had images I wanted inline and aligned to the right)
‘.widget_text img{
margin: 5px;
float: right;
width: 47px;
height: 31px;
display: inline-block;
}’
The topic ‘Widget in Header area’ is closed to new replies.
