roryashfordbentley / Wordpress-Bem-Menu

Better menu implementation for Wordpress using BEM syntax
139 stars 23 forks source link

You need to first define a menu in WP-admin #1

Closed sturobson closed 9 years ago

sturobson commented 9 years ago

This is, no doubt, an issue with my misunderstanding but...

I've pasted the relevant php into my functions.php and that seems to run smoothly. I've set menu location in wp-admin > 'primary'. I've added <?php bem_menu('primary', 'nav'); ?> into my header.php.

But I get - "You need to first define a menu in WP-admin" when I load up a page to see what happens.

Any ideas as to what I'm doing stupidly wrong?

tadywankenobi commented 9 years ago

Have you actually set values in the primary nav in the dashboard?

jdsteinbach commented 9 years ago

Assuming relevant php in functions.php means register_nav_menu('primary', 'Primary Menu') and you've created a menu in Dashboard, assigning it to that location…

bem_menu() is returning that error bc has_nav_menu('primary') is returning false (line 120), likely bc. that location hasn't been registered yet.

tadywankenobi commented 9 years ago

If you can show me how you've declared it in the functions. Also, your bem_menu function looks a little light. I usually do something like the following:

In the functions.php I have:

register_nav_menu('primary', 'Primary Nav');

And in the header.php I have:

wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => '', 'menu' => 'primary', 'container' => '', 'items_wrap' => '%3$s' ) );

You don't need the 'items_wrap" method. That just takes the content out of a UL in an individual LI, so I can add the search to a final li element so it's all in a list.

tadywankenobi commented 9 years ago

What does the function bem_menu do?

sturobson commented 9 years ago

seems, my theme needed me to add: register_nav_menu('primary', 'Primary Nav'); ... to functions.php and then set it in wp-admin. All working now. Thanks for all the replies :+1: :heart:

sturobson commented 9 years ago

@tadywankenobi it gives BEM naming convention to WP navigation. So nice and tidy, imho.