Created
December 18, 2013 21:00
-
-
Save illucent/8029761 to your computer and use it in GitHub Desktop.
wordpress nav
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 | |
$location = 'top_nav'; | |
if ( has_nav_menu( $location ) ) { | |
$args = array( | |
'theme_location' => 'top_nav', | |
'container' => '', | |
'container_class' => false, | |
'menu_class' => 'navigation_nav', | |
'menu_id' => 'top_navigation', | |
'echo' => true, | |
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', | |
'depth' => '1', | |
'fallback_cb' => 'wp_page_menu' ); | |
wp_nav_menu( $args ); | |
$menu_to_count = wp_nav_menu(array( | |
'echo' => false, | |
'theme_location' => 'top_nav', | |
'depth' => '1' | |
)); | |
$menu_items = substr_count($menu_to_count,'class="menu-item '); | |
$amount = 100; | |
$liwidth = (float)$amount / (int)$menu_items; | |
} ?> | |
<style> | |
#top_nav .navigation_nav > li { width: <?php echo $liwidth; ?>%; } | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment