如何从WooCommerce店面主题首页隐藏页面标题? [英] How to hide page title from WooCommerce Storefront theme homepage?

查看:255
本文介绍了如何从WooCommerce店面主题首页隐藏页面标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在首页上隐藏店面页面标题.这段代码从各个方面隐藏了它:

I am trying to hide the Storefront page title on my homepage. This code hides it from all the side:

function sf_change_homepage_title( $args ) {
    remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'init', 'sf_change_homepage_title' );

但是我不能使用is_front_page(),因为WordPress在$ wp_query对象与当前页面一起设置之前加载了functions.php,如

But I can't use is_front_page() because WordPress loads functions.php before the $wp_query object has been set up with the current page, as explained here.

我不希望使用插件"Title Toggle for Storefront Theme".

I would prefer not using the plugin "Title Toggle for Storefront Theme".

谢谢.

推荐答案

解决方案是将"init"替换为"wp":

The solution is to replace "init" with "wp":

add_action( 'wp', 'sf_change_homepage_title' );

谢谢.

这篇关于如何从WooCommerce店面主题首页隐藏页面标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆