我正在使用WooCommerce店面创建一个儿童主题。我正在尽可能多地使用挂钩,因为我知道这是最佳实践。
然而,即使在我删除了与此挂钩相关的所有操作之后,仍然有一个DIV:<div class="col-full"></div>
通过将其添加到我的主题函数中,我删除了这些操作。php文件
function remove_default_hooks() {
remove_action( \'storefront_header\', \'storefront_site_branding\', 20 );
remove_action( \'storefront_header\', \'storefront_secondary_navigation\', 30 );
remove_action( \'storefront_header\', \'storefront_primary_navigation_wrapper\', 42 );
remove_action( \'storefront_header\', \'storefront_primary_navigation\', 50 );
remove_action( \'storefront_header\', \'storefront_primary_navigation_wrapper_close\', 68 );
remove_action( \'storefront_header\', \'storefront_product_search\', 40 );
remove_action( \'storefront_header\', \'storefront_header_cart\', 60 );
remove_action( \'storefront_header\', \'storefront_skip_links\', 0);
remove_action( \'storefront_footer\', \'storefront_handheld_footer_bar\', 999 );
}
add_action( \'init\', \'remove_default_hooks\' );
如果我把钩子全部取下来,DIV就会消失。我已经搜索了WooCommerce插件和店面主题中的所有文件,但找不到这个DIV的来源。它也不在里面
header.php
DIV位于<header>
:
<header id="masthead" class="site-header fixed-top row no-gutters mt-0 pt-0 align-items-center" role="banner" style="">
<div class="col-full">
</div>
</header><!-- #masthead -->
在中显示如下
header.php
:
<header id="masthead" class="site-header fixed-top row no-gutters mt-0 pt-0 align-items-center" role="banner" style="<?php storefront_header_styles(); ?>">
<?php
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_skip_links - 0
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( \'storefront_header\' );
?>
</header><!-- #masthead -->
我找不到
add_action
对于
storefront_social_icons
.
如何删除这个恼人的DIV?
编辑:您可以在此处查看:Open Development Page
最合适的回答,由SO网友:user141080 整理而成
Storefront version 3.0:
Code of the header.php in version 3.0
<header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">
<?php
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_header_container - 0
* @hooked storefront_skip_links - 5
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_header_container_close - 41
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( \'storefront_header\' ); ?>
</header><!-- #masthead -->
在版本3.0中
<div class="col-full">
以及
</div>
将由挂钩“storefront\\u header\\u container”和“storefront\\u header\\u container\\u close”创建。您可以在文件中找到这两个挂钩的实现
storefront-template-functions.php要移除这些挂钩,可以执行以下操作:
function remove_default_hooks() {
remove_action( \'storefront_header\', \'storefront_header_container\', 0 );
remove_action( \'storefront_header\', \'storefront_header_container_close\', 0 );
}
add_action( \'init\', \'remove_default_hooks\' );
Storefront version 2.8 and smaller:
Code of the header.php in version 2.8
<header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">
<div class="col-full">
<?php
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_skip_links - 0
* @hooked storefront_social_icons - 10
* @hooked storefront_site_branding - 20
* @hooked storefront_secondary_navigation - 30
* @hooked storefront_product_search - 40
* @hooked storefront_primary_navigation_wrapper - 42
* @hooked storefront_primary_navigation - 50
* @hooked storefront_header_cart - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( \'storefront_header\' ); ?>
</div>
</header><!-- #masthead -->
在2.8及更小版本中
<div class="col-full">
以及
</div>
是标题的一部分。php文件。删除这两个html元素的唯一方法是覆盖标题。子模板中的php文件。