• Resolved hyacinthus

    (@hyacinthus)


    It’s me again. When I call wp_nav_menu(), I can put in some arguments like
    <?php wp_nav_menu(array('theme_location'=>'primary', 'menu_class'=>nav-menu'));?>
    Where in the codex or some tutorial is it explained what the terminology ‘primary’ means? I have browsed everything I can find about wp_nav_menu but what’s in the reference is pretty skimpy. How many locations are defined? What are they? What does ‘menu_class’ mean?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Look at “appearance->menus” on the dashboard on the “locations” tab. It will show you what menu locations are defined for your theme.

    If you’re developing your own theme, you can create locations with register_nav_menus

    https://codex.ww.wp.xz.cn/Function_Reference/register_nav_menus

    Thread Starter hyacinthus

    (@hyacinthus)

    I had already looked at the Function_Reference/register_nav_menus. It doesn’t help. I am working on my own theme. I have yet to find anything that helps understanding of how these things are defined. I have looked at the appearance->menus on the themes I’m currently running on my two websites and under the Manage Locations tab it says the current theme only supports one menu location but doesn’t give a clue to what it’s called. Would these things be defined in a .css file somewhere?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    no, not in CSS. Look in your theme for calls to register_nav_menus, probably in functions.php. It’s up to the theme to define menus and locations.

    Thread Starter hyacinthus

    (@hyacinthus)

    Okay. Here’s the function from TwentyThirteen. I look in these things to try to understand.

    // This theme uses wp_nav_menu() in one location.
    	register_nav_menu( 'primary', __( 'Navigation Menu', 'twentythirteen' ) );

    Where is ‘primary’ defined? Where is ‘Navigation Menu’ defined? I am used to looking up functions in Microsoft’s library for Windows Apps and finding all the parameters I can pass to a given function and finding them defined so I know how to use them. I’m finding WP very frustrating in this regard. The codex lists the arguments but it’s not clear what each means or its useage. theme_location is a prime example.

    • This reply was modified 9 years, 3 months ago by hyacinthus. Reason: found more information
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    ‘Primary’ is defined right there.

    If you wanted to define a 2nd menu named ‘secondary’, you’d use

    register_nav_menus( array ( 'primary'=>'this is the primary menu', 'secondary'=>'this is another menu' ) );

    Thread Starter hyacinthus

    (@hyacinthus)

    I think I finally figured out what my problem is. I keep forgetting that everything runs through the database. This has to be since users should be able to create menus in the admin interface. This means that functions like wp_nav_menu pull those menu items from the database. So ‘primary’ has no real meaning other than being a label. It could be called ‘february’ and it wouldn’t matter as long as you use it consistently. Where the menu gets located has nothing to do with template_location. The location on the web page depends on where you use wp_nav_menu and the styling depends on whatever styling is in effect at the time. Have I got this correct? If not, please clarify.
    Sure wish somebody would clarify this explicitly in the codex.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Correct.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘menu locations’ is closed to new replies.