Neve compatibility with Divi Header/Footer

If you are using the Neve (Pro) theme and want to use the Divi builder for the Header/Footer area, you may face some compatibility issues.

While we are investigating those problems in order to apply a fix directly in Neve's core, as a temporary fix, you can add the following code at the end of the functions.php file of your child theme.
For downloading a read-made child theme for Neve, please check this guide.

/**
 * Render Neve header when using Divi theme builder.
 * 
 * @param int $layout_id Layout id.
 * @param bool $layout_enabled Layout enabled.
 * @param int $template_id Template id.
 */
function my_theme_builder_custom_header( $layout_id, $layout_enabled, $template_id ) {
	// Only add the custom header if there is no Theme Builder header
	// being rendered and the header layout area is not disabled.
	if ( 0 === $layout_id && $layout_enabled ) {
		/**
		 * The template for displaying the header
		 *
		 * Displays all of the head element and everything up until the page header div.
		 *
		 * @package Neve
		 * @since   1.0.0
		 */

		$header_classes = apply_filters( 'nv_header_classes', 'header' );
		?><!DOCTYPE html>
		<html <?php language_attributes(); ?>>

		<head>
			<meta charset="<?php bloginfo( 'charset' ); ?>">
			<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
			<link rel="profile" href="http://gmpg.org/xfn/11">
			<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
				<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
			<?php endif; ?>
			<?php wp_head(); ?>
		</head>

		<body  <?php body_class(); ?> <?php neve_body_attrs(); ?> >
		<?php wp_body_open(); ?>
		<div class="wrapper">
			<header class="<?php echo esc_attr( $header_classes ); ?>" role="banner">
				<a class="neve-skip-link show-on-focus" href="#content" tabindex="0">
					<?php echo __( 'Skip to content', 'neve' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
				</a>
				<?php
				neve_before_header_trigger();
				if ( apply_filters( 'neve_filter_toggle_content_parts', true, 'header' ) === true ) {
					do_action( 'neve_do_header' );
				}
				neve_after_header_trigger();
				?>
			</header>
			<?php do_action( 'neve_before_primary' ); ?>

			<main id="content" class="neve-main" role="main">

		<?php
		do_action( 'neve_after_primary_start' );
	}
}
add_action( 'et_theme_builder_template_before_header', 'my_theme_builder_custom_header', 10, 3 );

/**
 * Render Neve footer when using Divi theme builder.
 *
 * @param int $layout_id Layout id.
 * @param bool $layout_enabled Layout enabled.
 * @param int $template_id Template id.
 */
function my_theme_builder_custom_footer( $layout_id, $layout_enabled, $template_id ) {
	// Only add the custom footer if there is no Theme Builder footer
	// being rendered and the footer layout area is not disabled.
	if ( 0 === $layout_id && $layout_enabled ) {
		// Render our custom footer, for example:
		/**
		 * The template for displaying the footer
		 *
		 * Contains the closing of the "wrapper" div and all content after.
		 *
		 * @package Neve
		 * @since   1.0.0
		 */

		do_action( 'neve_before_primary_end' );
		?>
			</main><!--/.neve-main-->

			<?php do_action( 'neve_after_primary' ); ?>

			<?php
			if ( apply_filters( 'neve_filter_toggle_content_parts', true, 'footer' ) === true ) {
				neve_before_footer_trigger();
				do_action( 'neve_do_footer' );
				neve_after_footer_trigger();
			}
			?>

			</div><!--/.wrapper-->
			<?php wp_footer(); ?>
	
			</body>
		
		</html>
		<?php
	}
}
add_action( 'et_theme_builder_template_after_footer', 'my_theme_builder_custom_footer', 10, 3 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us