Skip to content

Instantly share code, notes, and snippets.

@illucent
Created December 18, 2013 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illucent/8029761 to your computer and use it in GitHub Desktop.
Save illucent/8029761 to your computer and use it in GitHub Desktop.
wordpress nav
<?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