2016-06-10 57 views
3

我正在使用WordPress的WooCommerce主题店面的儿童主题。更改店面主题标题中的项目顺序

店面头钩功能是有序的这样:

<?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'); ?> 

我想更改顺序,因此product_search而来的secondary_navigation之前。

我已经通过店面文件,无法找到此订单的设置位置,只有项目单独。

任何人都可以请帮我钩或做什么是需要改变顺序吗?

回答

1

为了这个目的,你需要先用remove_action()功能删除它,然后你会add_action()功能又被勾它,改变从40的优先级为25

优先25位于之间:
@hooked storefront_site_branding - 优先级20 和@hooked storefront_secondary_navigation - 优先30

(在活动的子主题文件夹或更好)粘贴在您的活动主题文件夹的function.php此代码段:

remove_action('storefront_header', 'storefront_product_search', 40); 
add_action('storefront_header', 'storefront_product_search', 25); 
+0

感谢。但是,remove_action不起作用。我现在有两个product_search。任何想法为什么它不会删除? –

3

从@loictheaztec有人建议失踪下面ADD_ACTION -

add_action('init' , 'add_and_remove' , 15); 
function mh_add_and_remove() { 
     remove_action('storefront_header', 'storefront_product_search', 40); 
     add_action('storefront_header', 'storefront_product_search', 25); 
}