• Resolved ricardoc2

    (@ricardoc2)


    Hi Guys,

    I’m creating a wordpress theme for a school work.
    I have created my own HTML/CSS with bootstrap outside of wordpress and now i’m converting my HTML/CSS template into wordpress but i’m having some problemas with my menu.

    I have this code in functions.php to register the menu
    register_nav_menu( 'primary', 'Primary Menu' );

    Then i have my menu like this on header.php

    <nav class="navbar navbar-inverse navbar-fixed-top header" role="navigation">
            <div class="container">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="brand" href="<?php echo site_url(); ?>"><?php bloginfo('name'); ?></a>
                </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">
                      <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
                </div>
                <!-- /.navbar-collapse -->
            </div>
            <!-- /.container -->
        </nav>

    The problem is:
    When i choose my menu on wordpress dashboard the css classes that i have on my header are not working and wordpress are using weird classes when i use the inspector on firefox. Like this: http://prntscr.com/bf28lj

    How is wordpress doing this? And how can i change that?
    I work good with html/css but i’m a newbie in Javascript/PHP.

Viewing 1 replies (of 1 total)
  • Thread Starter ricardoc2

    (@ricardoc2)

    Ok, i figured it out.

    For the people with the same problem you have to define the css classes on header.php

    Like this:
    <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’ , ‘menu_class’ => ‘nav navbar-nav’) ); ?>

Viewing 1 replies (of 1 total)

The topic ‘CSS Classes on Menu’ is closed to new replies.