【问题标题】:Remove page title from woocommerce storefront theme homepage从 woocommerce 店面主题主页中删除页面标题
【发布时间】:2017-08-01 14:47:22
【问题描述】:

以前有人问过这个问题,我在这里尝试了许多解决方案,但没有一个对我有用。我已使用 woocommerce 店面主页模板将主页设置为静态页面,并希望删除页面标题标题。我尝试将此代码添加到我的functions.php,但它什么也没做,

if ( is_front_page() ) {
   remove_action( 'storefront_page', 'storefront_page_header' );
}

我已经尝试了以下答案:

How to hide page title from WooCommerce Storefront theme homepage?

&

WooCommerce StoreFront child theme - How to remove title on homepage

以下代码有效,但仅适用于商店页面。我找不到主页的条件标记。

function wc_hide_page_title()
{
    if( !is_shop() ) // is_shop is the conditional tag
        return true;
}
add_filter( 'woocommerce_show_page_title', 'wc_hide_page_title' );

任何人都可以在不使用插件的情况下帮助我做到这一点。谢谢!

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    如果您使用的是店面主页模板,那么您需要使用 storefront_homepage 操作。

    function wc_hide_page_title() {
        if( is_front_page() ) 
        remove_action( 'storefront_homepage', 'storefront_homepage_header', 10 );
    }
    add_action( 'woocommerce_show_page_title', 'wc_hide_page_title');
    

    【讨论】:

      【解决方案2】:

      试试这个

      function wc_hide_page_title() {
          if( is_front_page() ) 
              return true;
      }
      add_filter( 'woocommerce_show_page_title', 'wc_hide_page_title' );
      

      【讨论】:

        【解决方案3】:

        尝试使用以下代码在主页或任何特定页面上隐藏页面标题

        function wc_hide_page_title()
        {
            if( !is_page('home') ) // is_page is the conditional tag. 'home' is the page slug or use ID of the page instead of page slug.
            return true;
        }
        add_filter( 'woocommerce_show_page_title', 'wc_hide_page_title' );
        

        【讨论】:

          【解决方案4】:

          这在发布时有效:

          function jasom_dotnet_change_homepage_title( $args ) {
              if(is_front_page()) {
                  remove_action( 'storefront_page', 'storefront_page_header', 10 );
              }
          }
          add_action( 'wp', 'jasom_dotnet_change_homepage_title' );
          

          【讨论】:

            猜你喜欢
            • 2018-02-13
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2016-08-10
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2018-12-11
            相关资源
            最近更新 更多