2016-06-10 47 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); 
} 
相關問題