Removing content vs. display: none

I often see a question about this in Facebook groups. Someone asks a question about “how can I remove X” from my theme, or a page, or a footer. Most recently, I saw someone asking how to remove the message “Built with Storefront and WooCommerce” from their footer.

There is almost always someone who suggests to “just use a CSS rule and set the display to none”. This does have the appearance of removing that content from the page. So it looks like it’s gone, but it’s really still there.

Another suggestion is to use the Theme Customizer. There is an option to remove the credit link (that’s what it’s called) from the page. This is, in my opinion, much better. The content is actually removed from the page, rather than just being hidden from view.

Being a coder, my preferable solution is of course some code. Something like this would do the job:

<?php
add_action( 'wp_loaded', function () {
  remove_action( 'storefront_footer', 'storefront_credit', 20 );
});

You can put this code in your child theme’s function.php file, or a snippets plugin or any other way that you feel comfortable with adding it to your site.

So the question: which is better?

Hiding some text with a CSS rule doesn’t really remove the text from the page, so I don’t recommend this if you’re really trying to get rid of it. Search engines will still find the text “Built with Storefront” on the page, so this isn’t doing it. Just because it’s not being displayed does not mean that it’s removed.

A better option is to use the Theme Customizer, or theme options. If you’re not using Storefront and looking for a similar solution, your theme might still have a customization feature that will do this. It’s still much better than the CSS only solution. This method will completely remove the text in question and has the advantage of not requiring any coding — if you’re not a coder, this is a consideration. I feel this is the best option for most people.

If you do like the idea of a code solution, the above code snippet is probably of the greatest interest. It only works for the Storefront theme so if you’re using something else you’ll have to figure out how to make something similar work with your theme. But most themes do have some sort of hook or filter that will allow this.

To summarize, I feel that actually removing the content from the footer or page is the far better solution compared to just hiding it with a CSS rule. Since a CSS rule isn’t really removing the text anyway.

Leave a Comment

Your email address will not be published.