用短代码替换 Woocommerce Storefront header

Replacing Woocommerce Storefront header with a shortcode

我正在使用 Woocommerce Storefront 主题,我想用我在 elementor 中创建的自定义 header 替换原来的 header。我有新 header 的简码,但我不知道如何将其插入代码中。我使用的是空白店面 child 主题,并且有一个 function.php 文件和 style.css 文件。

感谢您的帮助。

只需从父主题复制 header.php 并将其粘贴到子主题中。然后您就可以将自定义代码放入其中。

参考:codex.wordpress.org/Child_Themes

您可以在 init

上使用钩子在您的子主题中执行此操作

像这样:

add_action('init', 'replace_header' );

function replace_header(){
    remove_action( 'storefront_header', 'storefront_primary_navigation', 50 );
    add_action('storefront_header', 'my_custom_header', 50);
}
function my_custom_header(){
    do_shortecode('[your_elementor_header_shortcode attr1="value1"]')
}