Skip to content

Instantly share code, notes, and snippets.

@renemorozowich
Last active October 11, 2019 13:25
Show Gist options
  • Save renemorozowich/02e94a6dee2f80da92473b7cec5c25f8 to your computer and use it in GitHub Desktop.
Save renemorozowich/02e94a6dee2f80da92473b7cec5c25f8 to your computer and use it in GitHub Desktop.
Add a top menu AND a bottom menu (after header) to an Astra child theme
/**
* Add additional menus
*/
function register_additional_menus() {
register_nav_menu( 'top-menu', __( 'Top Menu' ) );
register_nav_menu( 'bottom-menu', __( 'Bottom Menu' ) );
}
add_action( 'init', 'register_additional_menus' );
/**
* Add scripts to astra_header_before
*/
function add_script_before_header() {
?>
<div class="top-header-bar">
<div class="ast-container">
<?php wp_nav_menu( array( 'theme_location' => 'top-menu' ) ); ?>
</div>
</div>
<?php
}
add_action( 'astra_header_before', 'add_script_before_header' );
/**
* Add scripts to astra_header_after
*/
function add_script_after_header() {
?>
<div class="bottom-header-bar">
<div class="ast-container">
<?php wp_nav_menu( array( 'theme_location' => 'bottom-menu' ) ); ?>
</div>
</div>
<?php
}
add_action( 'astra_header_after', 'add_script_after_header' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment