wpPro offers design, development and full-service professional WordPress hosting service for serious bloggers web design web development professional WordPress hosting

wpPro offers design, development and full-service professional WordPress hosting service for serious bloggers

Anatomy of a Magazine Style Premium WordPress Theme - Part 3.1 “Navigation – Second Level Menu”

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Second Level Menu

The second level navigation is by far the easiest, tried and tested method of the three. Section 3.1 will cover the second level menu coding and it’s usage.

To add these second level navigation, we simple use the tags that generate a string of categories (or archives) and place them beneath the main navigation menu and style appropriately.

For example, to add a list of categories below the main menu, add the following code in the header.php (assuming your main menu is in the header):

  1. <?php wp_list_categories(’title_li=&hide_empty=0′); ?>

Note: the hide_empty tag unhides or hides unused categories.

Where to place the tag? Right below the template tag for page as described in the example below.

If we revisit the theme we created from the last exercise you will note that the main menu is displayed in the header in a single row.The code for this menu (simplified) looks like below:

  1. <div class=”wrap menu”>
  2. <div class=”right rss”>
  3. <a href=”<?php bloginfo(’rss2_url’); ?>” title=”RSS Feed”><img src=”<?php bloginfo(’stylesheet_directory’); ?>/images/rss.gif” alt=”RSS” /></a>
  4. </div>
  5. <ul>
  6. <li class=”<?php if ( is_home() or is_archive() or is_single() or is_paged() or is_search() or (function_exists(’is_tag’) and is_tag()) ) { ?>current_page_item<?php } else { ?>page_item<?php } ?>”><a href=”<?php echo get_settings(’home’); ?>”>Home</a></li>
  7. <?php wp_list_pages(’sort_column=menu_order&depth=1&title_li=’); ?>
    </ul>
  8. </div>

We will add the category code below it to generate the second layer menu. The code to add will look something like this:

  1. <div class=”subwrap submenu”>
  2. <ul>
  3. <?php wp_list_categories(’title_li=&hide_empty=0′); ?>
  4. </ul>
  5. </div>

To easily style this second level, use the existing style for the main menu and make minor changes to the display (colors and such). In this case, we will enclose this second level in a div called “subwrap submenu”, the main menu is within a div called “wrap menu”.

02.11.2008 - 7:22 pm - Design, How to, Resources, Tips - 323 views -

13 Responses to “Anatomy of a Magazine Style Premium WordPress Theme - Part 3.1 “Navigation – Second Level Menu””

Pages: [1] 2 3 »

  1. 1
    CleverSage Says:

    Awesome! I’ve never really been that technically-oriented, but you’re breaking down how these themes are made makes it so much easier to digest, thanks so much!

  2. 2
    Sunny Says:

    @ CleverSage

    Thank you. I am glad I could be of some use :-)

  3. 3
    Oz Says:

    Is it easy to customize the header on this theme w/ an image? I love it, but would like to plug in a logo instead of the text. Great work!

  4. 4
    Oz Says:

    Also - I notice that the posts are short and then say “Read More.” Does it only display a certain number of characters and then readers will need to click? Is that an option that can be turned off so that the entire post can be displayed?

  5. 5
    Website Design Linda Says:

    I love how you provide some code and explain the variations.

    For instance, the navigation in the header and the template ttag and code your provided.

Pages: [1] 2 3 »

Leave a Reply

Have Your Say »





Use SimpleCode while including codes.