Last active
August 29, 2015 14:09
-
-
Save juyal-ahmed/aefa3f66bf1c83fc74b9 to your computer and use it in GitHub Desktop.
wordpress-tb-menu.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* WordPress menu building THIS IS valid till you have a menu created by admin. | |
* | |
* Author: Jewel Ahmed | |
* Author Web: http://codeatomic.com | |
* Last Updated: 09 Nov, 2014 | |
*/ | |
$has_enabled_main_menu = false; | |
$menu_location = 'primary'; | |
$menu_locations = get_nav_menu_locations(); | |
$menu_object = ( isset( $menu_locations[ $menu_location ] ) ? wp_get_nav_menu_object( $menu_locations[ $menu_location ] ) : null ); | |
if( $menu_object ) { | |
$has_enabled_main_menu = true; | |
} | |
if( $has_enabled_main_menu ) { | |
wp_nav_menu( | |
array( | |
'theme_location' => 'primary', //Only allow this param if you think the menu already registered and assigned | |
'menu_class' => 'nav navbar-nav navbar-right', | |
'menu_id' => 'primary-menu', | |
'echo' => true, | |
'depth' => 3 | |
) | |
); | |
} else { | |
wp_nav_menu( | |
array( | |
'menu_class' => 'nav navbar-nav navbar-right', | |
'menu_id' => 'primary-menu', | |
'echo' => true, | |
'depth' => 3 | |
) | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment