Forums

The final word on custom menus? (6 posts)

  1. gmonk
    Member
    Posted 1 year ago #

    I've been all over the place looking for the best possible way to create custom menus in a theme and how to call the menu in a location on the theme. Some people write it one way, and some write it another...

    I thought I would just ask here and see anyone had a link they could give me that shows the most popular, or the most used, or just "the strict wordpress way" of doing this.

    I've also been having issues trying to link up my stylesheets. I have two: style.css and reset.css. They each reside in my 'stylesheets' directory in my theme folder (which I've named "loremipsum" for shits and giggles).

    Any help anyone could give would be super super swell!

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />

    is normally how style.css is loaded up, normally, style.css should be in your base theme folder, not it's own folder.....

    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_directory' ); ?>/folder/reset.css" />

    would load additional from a folder

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
    	) );

    is how you register a menu

    register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
                      'secondary' => __( 'Secondary Navigation', 'twentyten' ),
    
    	) );

    Is how you register two menus. the 'twentyten' localizes, it loads the text domain for translation. If you don't have that then instead of

    'primary' => __( 'Primary Navigation', 'twentyten' ),

    you could use

    'primary' => 'Primary Navigation',

    That's in functions.php. it registers/turns on the menus. You could then create the menus in appearance->menus

    To display them, you just call the menu

    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

    This loads the menu we registered above named primary. If you named the menu something different in functions.php when you named it, you would call it by that name here.

  4. gmonk
    Member
    Posted 1 year ago #

    Thanks alot, Voodoo! So if I needed to add a few more menus to my theme, would I then just do:

    register_nav_menus( array(
      'primary' => __( 'Primary Navigation', 'mythemename' ),
      'secondary' => __( 'Secondary Navigation', 'mythemename' ),
      'third_menu' => __( 'Third Menu', 'mythemename' ),
      'fourth_menu' => __( 'Fourth Menu', 'mythemename' ),
      )
    );

    And why do you suppose they're using double underscores? That's so confusing!

    So I think everything that I've seen so far have mostly been for wordpress 3.0, not 3.1. It can be a little confusing out there. There are a few differences in what I've been doing and now what you've posted. I'll give it a whirl! Thanks a ton, dude.

  5. fonglh
    Member
    Posted 1 year ago #

    the double underscores mark the text for translation purposes.

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    WP 3.0, and WP 3.1 are the same as far as menus go....

    You may see different code out there. It's possible to code things more than one way.

Topic Closed

This topic has been closed to new replies.

About this Topic