wp-bootstrap-navwalker icon indicating copy to clipboard operation
wp-bootstrap-navwalker copied to clipboard

Works on local, but not online

Open adamk22 opened this issue 13 years ago • 3 comments

I'm currently using wp-bootstrap-navwalker for a customized navigator for my bootstrap/wordpress website. It worked well locally using MAMP, but once I uploaded the theme and activate it on the online wordpress, I get the following errors:


Warning: Missing argument 2 for register_nav_menu(), called in /mnt/web5/c0/58/51640958/htdocs/adam/wp-content/themes/Adam/functions.php on line 178 and defined in /mnt/web5/c0/58/51640958/htdocs/adam/wp-includes/nav-menu.php on line 106

Warning: Illegal offset type in /mnt/web5/c0/58/51640958/htdocs/adam/wp-includes/nav-menu.php on line 107

Warning: Cannot modify header information - headers already sent by (output started at /mnt/web5/c0/58/51640958/htdocs/adam/wp-includes/nav-menu.php:106) in /mnt/web5/c0/58/51640958/htdocs/adam/wp-includes/option.php on line 571

Warning: Cannot modify header information - headers already sent by (output started at /mnt/web5/c0/58/51640958/htdocs/adam/wp-includes/nav-menu.php:106) in /mnt/web5/c0/58/51640958/htdocs/adam/wp-includes/option.php on line 572

The lines stated in nav-menu.php is as followed:

function register_nav_menu( $location, $description ) {
    register_nav_menus( array( $location => $description ) );
}

I'm not sure what the issue is.. I assume it has something to do with wordpress not able to register the navigator or something in that direction... how do I go about fixing this?

// EDIT:

Code in my functions.php:

function register_menus() {
    register_nav_menu( array('top_menu' => 'Top menu')
    );
}

And header.php:

<?php 
                    wp_nav_menu( array(
                        'menu'       => 'top_menu',
                        'depth'      => 2,
                        'container'  => false,
                        'menu_class' => 'nav',
                        'fallback_cb' => 'wp_page_menu',
                        //Process nav menu using our custom nav walker
                        'walker' => new wp_bootstrap_navwalker())
                    );
                ?>

adamk22 avatar Sep 23 '13 23:09 adamk22

That is an interesting issue.

The only problem I can see is that you haven't defined the theme_location variable in your wp_nav_menu() declaration. You must define the theme location inside your wp_nav_menu() in header.php as this is the variable that identifies your menu in the register_nav_menus()

<?php 
    wp_nav_menu( array(
        'menu'       => 'top_menu',
        'theme_location'  => 'top_menu',
        'depth'      => 2,
        'container'  => false,
        'menu_class' => 'nav',
        'fallback_cb' => 'wp_page_menu',
        'walker' => new wp_bootstrap_navwalker())
    );
?>

In wp_nav_menu() the menu variable actually defines the menu that you want to load from the WordPress menu manager.

That should clase up some of the issues. I'm not quite sure what they all are do you have a link?

SideQuestDIY avatar Sep 25 '13 15:09 SideQuestDIY

header information - headers already sent by (output started at /home/digmaweb/public_html/wordpress/wp-content/themes/digma/class-wp-bootstrap-navwalker.php:2) in /home/digmaweb/public_html/wordpress/wp-admin/includes/misc.php on line 1116

Warning: Cannot modify header information - headers already sent by (output started at /home/digmaweb/public_html/wordpress/wp-content/themes/digma/class-wp-bootstrap-navwalker.php:2) in /home/digmaweb/public_html/wordpress/wp-includes/option.php on line 919

Warning: Cannot modify header information - headers already sent by (output started at /home/digmaweb/public_html/wordpress/wp-content/themes/digma/class-wp-bootstrap-navwalker.php:2) in /home/digmaweb/public_html/wordpress/wp-includes/option.php on line 920

` add_action( 'after_setup_theme', 'register_my_menu' ); add_action( 'after_setup_theme', 'register_singel_page_menu' );

function register_my_menu() { register_nav_menu( 'main_menu', __( 'main menu ', 'theme-slug' ) ); }

function register_singel_page_menu() { register_nav_menu( 'singel_page_menu', __( 'singel page menu', 'theme-slug' ) ); } register_nav_menus( array( 'main_menu' => 'main menu', 'singel_page_menu' => 'singel page menu', ) ); function myNav() { wp_nav_menu(array(

	'theme_location'  => 'main_menu',
	'depth'	          => 2, // 1 = no dropdowns, 2 = with dropdowns.
	'container'       => 'div',
	'container_class' => 'navbar-collapse collapse clearfix',
	'container_id'    => 'bs-example-navbar-collapse-1',
	'menu_class'      => ' navigation clearfix',
	'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',
	'walker'          => new WP_Bootstrap_Navwalker(),


));

}

function my_singel_page_Nav() { wp_nav_menu(array(

	'theme_location'  => 'singel_page_menu',
	'depth'	          => 2, // 1 = no dropdowns, 2 = with dropdowns.
	'container'       => 'div',
	'container_class' => 'navbar-collapse collapse clearfix',
	'container_id'    => 'bs-example-navbar-collapse-1',
	'menu_class'      => ' navigation clearfix',
	'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',
	'walker'          => new WP_Bootstrap_Navwalker(),


));

}`

IslamAboAsd avatar May 22 '18 10:05 IslamAboAsd

Hey @eslam200788,

I am not certain why you would be getting this error. For you does it also work locally but not online same as the OP of this old issue?

If you could open a fresh issue with your problem that would help me keep track of it easier (and prevent us throwing notification emails at old participants in this one lol). I'll see the new issue if you make it.

pattonwebz avatar May 22 '18 12:05 pattonwebz