• Resolved orvokki

    (@orvokki)


    Hello everyone,

    I know there’ve been a lot of such questions but I really cannot handle my problem.
    I use a Bootstrap menu + Nav Walker class.
    Now I am trying to integrate the Polylang for the first time and I have a lot of problems, namely, the menu stays always German. I have 3 and have created for them 3 menus.

    I’ve read the topic above and have tried the code above but my PHP is not so good and it didn’t really work.
    I suppose it’s problem with my menu registering function.

    Here’s my code:

    <?php
    add_action( 'after_setup_theme', 'wpt_setup' );
        if ( ! function_exists( 'wpt_setup' ) ):
            function wpt_setup() {
                register_nav_menu( 'primary', __( 'Primary navigation', 'wptuts' ) );
            } endif;
    
    function wpt_register_js() {
        wp_register_script('jquery.bootstrap.min', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery');
        wp_enqueue_script('jquery.bootstrap.min');
    }
    add_action( 'init', 'wpt_register_js' );
    function wpt_register_css() {
        wp_register_style( 'bootstrap.min', get_template_directory_uri() . '/css/bootstrap.min.css' );
        wp_enqueue_style( 'bootstrap.min' );
        wp_enqueue_style( 'my_template', get_template_directory_uri() . '/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'wpt_register_css' );        
    
    // Register custom navigation walker
        require_once('wp_bootstrap_navwalker.php');
    ?>

    and HTML:

    <nav class="navbar navbar-default" role="navigation">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <h1><a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo get_stylesheet_directory_uri(); ?>/img/" alt ="" /></a></h1>
            </div>
            <div class="collapse navbar-collapse navbar-ex1-collapse">
              <?php /* Primary navigation */
              wp_nav_menu( array(
                   'primary',
    			'depth' => 1,
    			'container' => false,
    			'menu_class' => 'nav navbar-nav',
    			//Process nav menu using our custom nav walker
    			'walker' => new wp_bootstrap_navwalker())
    			);
    			?>
            </div>
          </nav>

    I would be really grateful for any help!

    https://www.ads-software.com/plugins/polylang/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Chrystl

    (@chrystl)

    Hi

    It lacks the ‘theme_location’:

    <?php /* Primary navigation */
              wp_nav_menu( array(
                            'theme_location' => 'primary',
    			'depth' => 1,
    			'container' => false,
    			'menu_class' => 'nav navbar-nav',
    			//Process nav menu using our custom nav walker
    			'walker' => new wp_bootstrap_navwalker())
    			);
    			?>
    Thread Starter orvokki

    (@orvokki)

    Thank you!!!:))

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Another menu problem ( Bootstrap Nav Walker)’ is closed to new replies.