WP主题中的Header默认作为为Elementor页头显示
问题:代码写的WP主题header头部,如何直接给Elementor新建页面使用。老的WP网站所有页面全部是代码写的,现在有新需求要,需要新设计几个Elementor落地页。但设计好Elementor页面后,发现原来网站的head菜单没有在elementor网页生效。
方案:
默认情况下,如果wp主题是按照规范写的,elementor页面可以自动显示header菜单。针对于非规范写的WP主题,我们可以短代码方式实现elementor引入header头部。
function.php 编辑自定义header头部
function my_head_shortcode() {
ob_start();
//header头部所有代码写的这个top.php文件中
get_template_part("template-parts/navigation/top");
return ob_get_clean();
}
add_shortcode('my_head', 'my_head_shortcode');

elementor引入shorcode元素,即可正确引用WP原本的header头部。