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

WP Bootstrap Nav walker disappeared after reloading template #532

Open
jakubkanna opened this issue Dec 30, 2021 · 3 comments
Open

WP Bootstrap Nav walker disappeared after reloading template #532

jakubkanna opened this issue Dec 30, 2021 · 3 comments

Comments

@jakubkanna
Copy link

I’m using Wordpress locally [MAMP-php caching turned off] and Bootstrap 5. I’m also using Polylang plugin.(so there was menu for each language).

The problem is wp-bootstrap-navwalker disapeard after removing and adding again Wordpress exact the same template. When logged out - it shows nothing. When logged in - it shows “Add Menu”. After clicking and creating new menu, still there is no new menu.

Browser console doesn’t show any error. I’ve already made sure, and followed once again every step of installing navwalker.

Any idea how to make it appear again?

@IanDelMar
Copy link
Collaborator

Hi! Could you please post the content of your header.php or whatever file is calling the menu and the ID of your menu?

@jakubkanna
Copy link
Author

Hi, for now I fixed it by using: [https://github.com/AlexWebLab/bootstrap-5-wordpress-navbar-walker]. But still I don’t know what was the reason of the issue.

header.php was standard like:

<?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package test
 */

?>
<!doctype html>
<html <?php language_attributes(); ?>>

<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="profile" href="https://gmpg.org/xfn/11">
	<?php wp_head(); ?>




</head>

<body class="d-flex flex-column min-vh-100" id="body">



<?php wp_body_open(); ?>


<header id="masthead" class="site-header">

<nav class="navbar navbar-expand-md navbar-light bg-light" role="navigation">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-controls="bs-example-navbar-collapse-1" aria-expanded="false" aria-label="<?php esc_attr_e( 'Toggle navigation', 'your-theme-slug' ); ?>">
        <span class="navbar-toggler-icon"></span>
    </button>
    <a class="navbar-brand" href="#">Navbar</a>
        <?php
        wp_nav_menu( array(
            'theme_location'    => 'primary',
            'depth'             => 2,
            'container'         => 'div',
            'container_class'   => 'collapse navbar-collapse',
            'container_id'      => 'bs-example-navbar-collapse-1',
            'menu_class'        => 'nav navbar-nav',
            'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
            'walker'            => new WP_Bootstrap_Navwalker(),
        ) );
        ?>
    </div>
</nav>


<?php get_search_form();?>

</div>

</header><!-- #masthead -->
<?php

@IanDelMar
Copy link
Collaborator

The header.php seem to be fine as long as you registered the menu location "primary".

The problem is wp-bootstrap-navwalker disapeard after removing and adding again Wordpress exact the same template. When logged out - it shows nothing. When logged in - it shows “Add Menu”. After clicking and creating new menu, still there is no new menu.

This is the behavior of the fallback. The walker does not recognize the menu. Can you please verify that there is a menu location "primary" and that a menu is assigned to that location?

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

No branches or pull requests

2 participants