Have you noticed that in the Storefront theme there are footer credits for the theme itself and WooCommerce?
It is possible to hide those credits from the Customizer in the Footer section, but it’s nice to keep them around to support the developers. It might be useful though to add your company name as well or change the text to something else that you prefer.
You can do it, as always, via custom code!
This time it’s not a simple snippet though. The only filter that we have for the footer credits is storefront_credit_link
, but this one is used to simply hide the entire thing.
We don’t want to do that, also because we have an option for it. We have to use a different method.
Did you know that many of the Storefront functions are pluggable? What does it mean? It means that you can declare a function with the same name of the one included in the theme/plugins without creating a fatal error, and your function will completely replace the one from the core.
The name of the function that prints the footer credits is storefront_credit
and you can find it in /wp-content/themes/storefront/inc/storefront-template-functions.php
on line 125.
Let’s replace it. Open your functions.php file in wp-content/themes/your-child-theme-name/ and add this code at the end of the file:
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
/** | |
* Display the theme credit | |
* | |
* @since 1.0.0 | |
* @return void | |
*/ | |
function storefront_credit() { | |
?> | |
<div class="site-info"> | |
<?php echo esc_html( apply_filters( 'storefront_copyright_text', $content = '© ' . get_bloginfo( 'name' ) . ' ' . date( 'Y' ) ) ); ?> | |
<?php if ( apply_filters( 'storefront_credit_link', true ) ) { ?> | |
<br /> <?php echo '<a href="https://woocommerce.com" target="_blank" title="' . esc_attr__( 'WooCommerce – The Best eCommerce Platform for WordPress', 'storefront' ) . '" rel="author">' . esc_html__( 'Built with Storefront & WooCommerce', 'storefront' ) . '</a>' ?> by <a href="https://yourdomain.com" title="Your Company Name">Your Company Name</a>. | |
<?php } ?> | |
</div><!– .site-info –> | |
<?php | |
} |
This snippet will add a link to your company after the default footer credits. All this is done where you see this code:
by <a href="https://yourdomain.com" title="Your Company Name">Your Company Name</a>.
Just replace these data with your company’s data or anything you prefer, and you’re done!
Leave a Reply