Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent errors occurring when there is no menu or link #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

evokelektrique
Copy link

Today I tried this Walker and I didn't had any menus registered so I encountered an error in line 36 and 15, This pull request fixed those issues.

@mbrughi
Copy link

mbrughi commented Oct 15, 2021

It is possible to avoid the error by checking that there is actually an assigned menu before trying to use the location:

		        if (has_nav_menu('primary')) {
			        wp_nav_menu( array(
			            'theme_location'    => 'primary',
			            'depth'             => 0,
			            'container'         => false,
			            //'items_wrap'     => 'div',
			            'menu_class'        => 'navbar-menu',
			            'menu_id'           => 'primary-menu',
			            'after'             => "</div>",
			            'walker'            => new Navwalker())
			        );
			    }    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants