0

I'm totally beginer in Wordpress and PHP. I am trying to move the page code in HTML with my own CSS to Wordpress and PHP. I have a problem with the menu. I think I am doing something wrong and I can't find a mistake.

I have a menu in my theme in HTML:

<nav id="mainNav" class="navbar navbar-default navbar-fixed-top">

<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span>Menu</span>
    </button>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav navbar-left">
        <li>
            <a class="page-scroll nav-width" href="#page_1">Page_01</a>
        </li>
        <li>
            <a class="page-scroll nav-width" href="#page_2">Page_02</a>
        </li>
        <li>
            <a class="page-scroll nav-width" href="#page_3">Page_03</a>
        </li>
        <li>
            <a class="page-scroll nav-width" href="#page_4">Page_04</a>
        </li>
        <li>
            <a class="page-scroll nav-width" href="#page_5">Page_05</a>
        </li>
        <li>
            <a class="page-scroll nav-width" href="#page_6">Page_06</a>
        </li>
    </ul>
</div>
<!-- /.navbar-collapse -->

I registered my menu in functions.php:

<?php register_nav_menu( 'main', 'main_menu' ); ?>

and I try to put my menu it to the header.php usung this code:

<nav id="mainNav" class="navbar navbar-default navbar-fixed-top">

<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
    <span>Menu</span>
    </button>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

<!--menu-->
<?php wp_nav_menu( array( 
        'menu' => '',
        'container' => 'ul',
        'container_class' => 'nav navbar-nav navbar-right',
        'container_id' => '',
        'menu_class' => 'nav navbar-nav navbar-left page-scroll nav-width',
        'menu_id' => '',
        'echo' => true,
        'fallback_cb' => 'wp_page_menu',
        'before' => '',
        'after' => '',
        'link_before' => '',
        'link_after' => '',
        'items_wrap' => '<ul id="" class="nav navbar-nav navbar-right" role="menu" ></ul>',
        'item_spacing' => '',
        'depth' => 0,
        'walker' => '',
        'theme_location' => 'main' 
    ) ); ?>

</div>
<!-- /.navbar-collapse -->
</nav>

When I'm creating a menu in Wordpress it doesn't work, menu isn't displayed on my page. What is wrong with this code?

I will be grateful for your help :)

AnnGro
  • 1

1 Answers1

-1

i think you using bootstrap right?

for bootstrap there is a very nice navwalker...
just include the file and follow the documentation
https://github.com/wp-bootstrap/wp-bootstrap-navwalker

Tobias
  • 1,534
  • 11
  • 25