【问题标题】:WooCommerce StoreFront child theme - How to remove title on homepageWooCommerce StoreFront 子主题 - 如何删除主页上的标题
【发布时间】:2016-12-10 18:45:59
【问题描述】:

你知道有什么钩子或过滤器可以删除 StoreFront 主题首页上的标题吗?

我尝试了几种解决方案,但没有任何效果。我使用 Storefront 的子主题(Woothemes 的文具)。

感谢您的帮助。

【问题讨论】:

  • 您是否使用静态首页。或者你有任何模板。
  • FrontPage/stationery 有一个主页模板,所以它是一个带有“主页”模板的静态页面。
  • 您是否尝试过使用 css 隐藏此页面的标题。
  • 不,因为我真的想从 HTML 中删除它,不仅用 css 隐藏它,这将是我最后的选择。
  • 这个插件你试过了吗:wordpress.org/plugins/storefront-title-toggle

标签: wordpress filter woocommerce hook


【解决方案1】:

我搜索了更多详细信息。请试试这个

if ( is_page('page id') )
{
      add_filter( 'the_title', '__return_false' );
}

【讨论】:

    【解决方案2】:

    尝试将此代码添加到functions.php

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

    这应该删除(包括)之间的所有内容:

    <header class="entry-header">
        <?php
            storefront_post_thumbnail( 'full' );
            the_title( '<h1 class="entry-title">', '</h1>' );
        ?>
    </header><!-- .entry-header -->
    

    【讨论】:

    • 谢谢!它工作得很好,昨天我尝试了相同的代码,但使用了 is_home()。只是一个更正:它是“is_front_page()”。再次感谢!!!
    • 是的,这些令人困惑conditional tags。 is_home() 在主帖子(博客)页面上返回 TRUE,而 is_frontpage() 在主帖子页面或主静态页面上为 TRUE(取决于您在 Settings->Reading 中选择的选项)
    【解决方案3】:

    我在这里和其他帖子中尝试了所有示例,并且在 init 钩子中运行 remove_action 后它起作用了,如下所示:

    function wc_hide_page_title() {
        remove_action( 'storefront_page', 'storefront_page_header' );
    }
    add_action( 'init', 'wc_hide_page_title');
    

    【讨论】:

      猜你喜欢
      • 2016-08-10
      • 2017-08-01
      • 2023-04-05
      • 2018-02-13
      • 2016-09-12
      • 2019-07-08
      • 1970-01-01
      • 1970-01-01
      • 2018-04-26
      相关资源
      最近更新 更多