Skip to content
This repository has been archived by the owner on Feb 10, 2020. It is now read-only.

Menu Configuration #10

Open
tinhop opened this issue Sep 25, 2019 · 1 comment
Open

Menu Configuration #10

tinhop opened this issue Sep 25, 2019 · 1 comment

Comments

@tinhop
Copy link

tinhop commented Sep 25, 2019

Hello, I am creating an HTML page with bootstrap 4, and my idea is to configure it to walk with wordpress and its cms environment, the texts and other settings with Custom Fields and now in the final stages I am having problems configuring my menu, I was recommended to use your plugin, but I am having problems configuring it. I tried the base installation, but I did not get it, so I am seeing to change the lines of code within the pages that you indicate, but I am not getting it

i got this lines acording to the menus on my functions.php file

/*menues support*/

add_theme_support('menus');

/*register menues*/


register_nav_menus(

    array( 
            'top menu' => __('Top Menu', 'theme'),
        )

    );

    // Register Custom Navigation Walker
require_once get_template_directory() . '/wp-bootstrap-navwalker.php';

and then on mi header.php file

<body>

 <header>
  <div>
   <?php
$custom_logo = wp_get_attachment_image( get_theme_mod( 'custom_logo' ), 'full' );
?>

<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between">

  <a class="navbar-brand" href="<?php echo home_url() ?>">
    <?php echo $custom_logo ?>
  </a>

  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <?php
  wp_nav_menu( array(
      'theme_location'  => 'top-menu',
      'depth'           => 2,
      'container'       => 'div',
      'container_id'    => 'navbarNavDropdown',
      'container_class' => 'collapse navbar-collapse',
      'menu_class'      => 'nav navbar-nav ml-auto',
      'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',
      'walker'          => new WP_Bootstrap_Navwalker()
  ) );
  ?>
</nav>
  </div><!--container-->
  </header>

and what the page returns to me in preview mode is this, and I can't configure the menu with the corresponding links

image

@jprieton
Copy link
Owner

jprieton commented Sep 26, 2019

Hello, when register nav menus you use this code

register_nav_menus(
    array( 
            'top menu' => __('Top Menu', 'theme'),
        )
    );

And when you call the menu in the args use

 'theme_location'  => 'top-menu',

Notice the difference in the menu id; 'top menu' when is declared and 'top-menu' when is used in args

EDIT
The menu ID should be like a slug, without spaces

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

No branches or pull requests

2 participants