编程语言
首页 > 编程语言> > php – 更改Storefront Theme Header中项目的顺序

php – 更改Storefront Theme Header中项目的顺序

作者:互联网

我正在使用Wordpress,WooCommerce主题店面的儿童主题.

Storefront标头钩子函数以这种方式排序:

<?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之前到来.

我已经浏览了店面文件,无法找到此订单的设置位置,只能找到单独的项目.

任何人都可以帮我勾选或做一些改变订单所需的东西吗?

解决方法:

来自@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 );
}

标签:php,wordpress,woocommerce,wordpress-theming,storefront
来源: https://codeday.me/bug/20190829/1757848.html