I am using storefront theme by woocommerce. I need to remove homepage title (h1) with php, i know css solution, but i don’t want to use it, because i want to add h1 to other place in that page and it’s bad for seo to have 2 h1’s in one page! I also know about plugins that remove page title, but they are working as css display:none; property!
I tried all the snippets that i could find in web, but no luck!
Here is my site domain BrightBells.com
Here is PHP code snippets that i tried one by one by adding to my functions.php file, but none of its help!
Snippet 1
function wc_hide_page_title() {
if( is_front_page() )
return true;
}
add_filter( 'woocommerce_show_page_title', 'wc_hide_page_title' );
Snippet 2
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'init', 'sf_change_homepage_title' );
Snippet 3
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'wp', 'sf_change_homepage_title' );
Snippet 4
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'after_setup_theme', 'sf_change_homepage_title' );
Snippet 5
function sf_change_homepage_title( $args ) {
if(is_front_page()) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
}
add_action( 'init', 'sf_change_homepage_title' );
Snippet 6
if ( is_front_page() ) {
remove_action( 'storefront_page', 'storefront_page_header' );
}
Snippet 7
if ( is_page('page id') )
{
add_filter( 'the_title', '__return_false' );
}
None of this snippets help, please help!
Here is page settings screenshots!
setting page screenshot
page screenshot
Thanks in advance
2
Answers
Try this —
I hope you are using a child theme or plugin in doing this.
Because it will just be removed when your theme updates.
In storefront version 2.2.5, it can be done with this code:
Update:
if on a child theme please do something like this:
Child themes are run first before the parent theme. By doing so, we will define this
storefront_homepage_header
function first. In that case, the parent theme will not create it. Applicable only on themes that usesfunction_exists
, luckily, storefront does.remove_action
will not work because the action has not been added yet.