Forums

[resolved] How add parameters to this line of code? (2 posts)

  1. vytaulla51
    Member
    Posted 1 year ago #

    Hi:
    I'm working my way through this problem and think I might have reached the nub of the problem.

    I have created my own theme. I need 2 navbars - one for pages, and one for blog related links. I "menu-enabled" my theme and created my primary navbar, and am calling it with this:
    <?php wp_nav_menu( array( 'theme_location' => 'navbar-menu' )); ?>

    I'm not a php programmer so this is, I think, a newbie question -

    I have the navbar designed and coded it in html/css. So I have css styles figured out to make it look like I want and to where I want. I use a javascript for the dropdowns.
    The styles in my stylesheet are:

    /*Navbar*/
    #navbar {width: 100%; height: 24px; }
    #navbar ul {margin: 0 0 0 73px; padding: 0px; }
    #navbar ul li {display: inline; height: 30px; float: left; list-style: none;
    margin-left: 5px; margin-right: 5px; position: relative;
    }
    #navbar a:link { color: #FFF;  text-decoration: none; }
    #navbar a:visited { color: #FFF; text-decoration: none; }
    #navbar a:hover { color: #FF3;  text-decoration: none; }
    #navbar a:active { color: #FFF; text-decoration: none; }
    
    /*Navbar sub menus*/
    #navbar li ul { margin: 0; padding: 7px 0 0 11px; height: 53px; display: none; position: absolute; left: 0; top: 23px; background-color: #426186; background-image: url(images/droptile.jpg); background-repeat: repeat-x; }
    #navbar li:hover ul { display: block; width: 130px; }
    #navbar li li {display: list-item; list-style: none; }
    #navbar li li a:link { color: #FFF;  text-decoration: none; }
    #navbar li li a:visited { color: #FFF; text-decoration: none;}
    #navbar li li a:hover { color: #FF3; text-decoration: none; }
    #navbar li li a:active { color: #FFF; text-decoration: none; }

    I think that to get my navbar to reference my styles I need to add css parameters as described in the article: http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus

    It says:

    You’re allowed even more control. wp_nav_menu() has several parameters you can use when displaying a menu.

    * theme_location: The menu to call that is associated with the specific theme location.
    * menu: Call a specific menu ID, slug, or name.
    * container: The element that wraps around the list. The default is div but can be changed to nav if you’ve moved on to HTML 5.
    * container_class: The CSS class of the container.
    * menu_class: The CSS class given to the unordered list. This defaults to menu.

    I'm not a php programmer and don't know how to put this together properly.

    Can someone advise?

    Thanks!!

  2. vytaulla51
    Member
    Posted 1 year ago #

    figured it out.

    Needed to change my code to:
    <?php wp_nav_menu( array( 'container_id' => 'navbar', 'theme_location' => 'navbar-menu' )); ?>

    Needed to add the 'container_id' => 'navbar" and it worked.
    Yay!

Topic Closed

This topic has been closed to new replies.

About this Topic