删除woocommerce店面首页标题php [英] remove woocommerce storefront homepage title php
问题描述
我正在使用woocommerce的店面主题.我需要用php删除主页标题(h1),我知道css解决方案,但是我不想使用它,因为我想将h1添加到该页面的其他位置,对于seo来说,在一个页面中放置2个h1很不好页!我也知道删除页面标题的插件,但是它们作为CSS display:none;起作用.财产!
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!
这是我的网站域BrightBells.com
Here is my site domain BrightBells.com
以下是我通过添加到我的functions.php文件中一步一步尝试的PHP代码段,但没有帮助!
Here is PHP code snippets that i tried one by one by adding to my functions.php file, but none of its help!
代码段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' );
}
这些代码片段均无帮助,请帮助!
None of this snippets help, please help!
这是页面设置的屏幕截图! 设置页面屏幕截图
Here is page settings screenshots! setting page screenshot
页面截图 预先感谢
推荐答案
我希望您正在使用子主题或插件. 因为它将在您的主题更新时被删除.
I hope you are using a child theme or plugin in doing this. Because it will just be removed when your theme updates.
在店面版本2.2.5中,可以使用以下代码完成此操作:
In storefront version 2.2.5, it can be done with this code:
remove_action( 'storefront_homepage', 'storefront_homepage_header', 10 );
更新:
如果是儿童主题,请执行以下操作:
Update:
if on a child theme please do something like this:
if ( ! function_exists( 'storefront_homepage_header' ) ) {
function storefront_homepage_header() { }
}
子主题首先在父主题之前运行.这样,我们将首先定义此storefront_homepage_header
函数.在这种情况下,父主题将不会创建它.幸运地,店面仅适用于使用function_exists
的主题.
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 uses function_exists
, luckily, storefront does.
remove_action
将不起作用,因为尚未添加操作.
remove_action
will not work because the action has not been added yet.
这篇关于删除woocommerce店面首页标题php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!