Customizing the links in the handheld footer bar is fairly straightforward and handled via the storefront_handheld_footer_bar_links
filter.
Removing a link
↑ Back to topUsing the following snippet would remove all links. Pick and choose according to which you want to keep.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'storefront_handheld_footer_bar_links', 'jk_remove_handheld_footer_links' ); | |
function jk_remove_handheld_footer_links( $links ) { | |
unset( $links['my-account'] ); | |
unset( $links['search'] ); | |
unset( $links['cart'] ); | |
return $links; | |
} |
Removing all links
↑ Back to topTo remove the feature altogether you can use something like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', 'jk_remove_storefront_handheld_footer_bar' ); | |
function jk_remove_storefront_handheld_footer_bar() { | |
remove_action( 'storefront_footer', 'storefront_handheld_footer_bar', 999 ); | |
} |
Adding a link
↑ Back to topAdding a link is more involved. We use the same filter but also need to declare a callback function to display the link itself. This snippet will add a ‘home’ link:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'storefront_handheld_footer_bar_links', 'jk_add_home_link' ); | |
function jk_add_home_link( $links ) { | |
$new_links = array( | |
'home' => array( | |
'priority' => 10, | |
'callback' => 'jk_home_link', | |
), | |
); | |
$links = array_merge( $new_links, $links ); | |
return $links; | |
} | |
function jk_home_link() { | |
echo '<a href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Home' ) . '</a>'; | |
} |
The layout automatically arranges itself based on the number of links in the navigation bar. After adding this snippet, you’d see something like this:
Now the link is in place, but it’s missing an icon.
We need to add some CSS. Since FontAwesome is bundled in Storefront, pick and use an icon from that set.
- Find the icon you want to use on the FontAwesome site and locate its unicode value. In this case we’ll use the home icon which has a unicode value of
f015
. - Here’s the CSS you need for the home link we created.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.storefront-handheld-footer-bar ul li.home > a:before { | |
content: "\f015"; | |
} |
Note that the class name applied to the list item is based on your code in the snippet, which adds the link. If you’re using something other than ‘home,’ you need to change it.
Here’s the finished result: