The Storefront theme is one of the most popular WooCommerce themes. As of today, it has 200,000 active installations and 4.5/5 ratings, as well as a great overall performance.
But sure, you can’t win them all. Storefront is missing an important feature: the top bar. That’s a pity, because most ecommerce themes have either a dedicated widget area or somewhere you can add content in the theme options.
So, let’s go fix that. Here’s how to add a top bar with a background to your Storefront theme. Enjoy!
PHP Snippet: Add Top Bar to Storefront Theme
/**
* @snippet Top Bar For Storefront Theme
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_action( 'storefront_before_header', 'bbloomer_storefront_top_bar' );
function bbloomer_storefront_top_bar() {
?>
<div class="sf-top-bar">
<div class="col-full">
Your text here
</div>
</div>
<?php
}
And a bit of CSS for styling the top bar:
.sf-top-bar {
text-align: center;
padding: 0.2em 0;
background: #E11F27;
color: white;
}
Hello, thank you for posting this code. My problem is that I use the sticky header option and it pushes the top bar below it. Any idea how to get above the sticky header?
Hi Joe, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!