Skip to content

Adding Header Footer Elementor support for your theme

sujaypawar edited this page Sep 15, 2017 · 9 revisions

If you are a theme developer, you can add support for Header Footer Elementor very easily!

The main idea here is to disable the header and footer added by your theme hooks for allowing the plugin to render the header/footer.

There can be multiple ways to disable default header/footer from the theme. If your theme supports actions and filters for rendering the markup of header/footer, the cleanest approach would be to remove original actions.

For eg -

For Astra Theme Header can be disabled by removing the actions

remove_action( 'astra_header', 'astra_header_markup' );

For rendering the header from plugin, just call the HFE's function to render the header in its place

function your_prefix_render_hfe_header() {
	
	if ( function_exists( 'hfe_render_header' ) ) {
		hfe_render_header();
	}

}

add_action( 'astra_header', 'your_prefix_render_hfe_header' );

Same process goes for adding the Footer support, Disable default footer and then render the footer from the plugin from function hfe_render_footer()

After you have added support for both header and the footer be sure to test the functionalities with your theme and then declare theme support for header-footer-elementor to disable the admin notice for unsupported themes.

function your_prefix_header_footer_elementor_support() {
	add_theme_support( 'header-footer-elementor' );
}

add_action( 'after_setup_theme', 'your_prefix_header_footer_elementor_support' );

Check out the file Astra Theme Compatibility Class for more information for complete implementation.

If you face any issues, Feel free to open up a new issue and I will be glad to fix the problem.