Skip to content

Instantly share code, notes, and snippets.

@jamesfosker
Last active November 22, 2018 23:38
Show Gist options
  • Save jamesfosker/329d7ab89a1ed702aa723c72645d909d to your computer and use it in GitHub Desktop.
Save jamesfosker/329d7ab89a1ed702aa723c72645d909d to your computer and use it in GitHub Desktop.
function custom_divi_header() {
//Insert HTML here
}
add_action( 'et_html_main_header', 'custom_divi_header' );
<?php
$logo = ( $user_logo = et_get_option( 'divi_logo' ) ) && '' != $user_logo
? $user_logo
: $template_directory_uri . '/images/logo.png';
ob_start();
?>
<div class="logo_container">
<span class="logo_helper"></span>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<img src="<?php echo esc_attr( $logo ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" id="logo" data-height-percentage="<?php echo esc_attr( et_get_option( 'logo_height', '54' ) ); ?>" />
</a>
</div>
<?php
$logo_container = ob_get_clean();
/**
* Filters the HTML output for the logo container.
*
* @since ??
*
* @param string $logo_container
*/
echo apply_filters( 'et_html_logo_container', $logo_container );
?>
<?php
$menuClass = 'nav';
if ( 'on' == et_get_option( 'divi_disable_toptier' ) ) $menuClass .= ' et_disable_top_tier';
$primaryNav = '';
$primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => 'top-menu', 'echo' => false ) );
if ( '' == $primaryNav ) :
?>
<ul id="top-menu" class="<?php echo esc_attr( $menuClass ); ?>">
<?php if ( 'on' == et_get_option( 'divi_home_link' ) ) { ?>
<li <?php if ( is_home() ) echo( 'class="current_page_item"' ); ?>><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Home', 'Divi' ); ?></a></li>
<?php }; ?>
<?php show_page_menu( $menuClass, false, false ); ?>
<?php show_categories_menu( $menuClass, false ); ?>
</ul>
<?php
else :
echo( $primaryNav );
endif;
?>
</nav>
function custom_divi_header() {
echo do_shortcode('[et_pb_section global_module="xxx"][/et_pb_section]'); // Change XXX to library items id (you can find the library item id when editing the library item if you look in the url bar you will see number after .mysite.com/wp-admin/post.php?post=xxx )
}
add_action( 'et_html_main_header', 'custom_divi_header' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment