我正在使用 woocommerce 的店面主题。我需要用 php 删除主页标题(h1),我知道 css 解决方案,但我不想使用它,因为我想将 h1 添加到该页面的其他位置,并且在一个页面中包含 2 个 h1 对 seo 不利页!我也知道删除页面标题的插件,但它们的工作方式是 css display:none;财产!
我尝试了在网络上可以找到的所有片段,但没有运气!
这是我的网站域名 BrightBells.com
这是我通过添加到我的functions.php文件中一一尝试的PHP代码片段,但没有任何帮助!
片段1
function wc_hide_page_title() {
if( is_front_page() )
return true;
}
add_filter( 'woocommerce_show_page_title', 'wc_hide_page_title' );
片段2
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'init', 'sf_change_homepage_title' );
片段3
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'wp', 'sf_change_homepage_title' );
片段4
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'after_setup_theme', 'sf_change_homepage_title' );
片段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' );
片段6
if ( is_front_page() ) {
remove_action( 'storefront_page', 'storefront_page_header' );
}
片段7
if ( is_page('page id') )
{
add_filter( 'the_title', '__return_false' );
}
这些片段都没有帮助,请帮忙!
这是页面设置截图!设置页面截图 https://i.stack.imgur.com/IfDgo.png
页面截图 https://i.stack.imgur.com/TMQXZ.png提前致谢