Created
September 9, 2014 10:12
-
-
Save richlloydmiles/6a7e051af2478f073616 to your computer and use it in GitHub Desktop.
Count menu items
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 | |
ob_start(); | |
wp_nav_menu(array('theme_location' => 'primary', 'menu_class' => 'nav navbar-nav')); | |
$output = htmlspecialchars(ob_get_contents()); | |
ob_end_clean(); | |
$menu_items = substr_count($output,'li class'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the most effective method I can find, probably not the best though.