Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the Menubar plugin to place a menu at the top of my website. However, I need to find a way to check if the menu contains items or not. My menu is called 'menubar'. Currently, I'm loading the menu like so:

do_action('wp_menubar', "menubar");

It loads fine, but I need to check if there are items in it or not so I can adjust and display other things instead. Any ideas? Or is this question too vague?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Try this:

 $meniu = count(wp_nav_menu( array('menu' => 'menubar' )));
                       if($meniu > 0 ){
                           //here goes your stuff if we have items in menu
                       }
share|improve this answer
    
You may want to prevent the display by adding 'echo' => FALSE, to the first wp_nav_menu argument. –  Nabil Kadimi Feb 10 at 12:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.