Add a Second Menu to a theme that only support 1 menu

I am no programmer but I can usually work stuff like this out when I read the code.

I have a theme called Infinity which only supports 1 menu. I know how to do CSS etc but I can’t find how I would a second menu. In fact it doesn’t have to be a custom menu but just the pages. Can anyone tell me how to do this? An excerpt of the code is below which appears to load the menu:

Read More
<div class="container_main">
<div class="container_12_head">
<?php get_template_part( 'custom', 'header' ); ?>

<div class="clear"></div>
</div>
  <div class="container_head_menu_wrap">
  <div class="container_12_head">
  <?php get_template_part( 'primary', 'menu' ); ?>
  <div class="clear"></div>
  </div>
</div>

This code is in the header.php. I search for primary primary-menu.php and found this in it:

<?php
/** Primary Menu Callback */
function infinity_primary_menu_cb() {
    wp_page_menu();      
}
?>
<div class="grid_8 alpha">
  <div class="menu1">
    <div class="menu1-data">
      <?php
      if ( has_nav_menu( 'infinity-primary-menu' ) ):

        $args = array(

            'container' => 'div', 
            'container_class' => 'primary-container', 
            'theme_location' => 'infinity-primary-menu',
            'menu_class' => 'sf-menu1',
            'depth' => 0,
            'fallback_cb' => 'infinity_primary_menu_cb'

        );

        wp_nav_menu( $args );

      else:

        infinity_primary_menu_cb(); 

      endif;
      ?>
      <div class="clear"></div>
    </div>
  </div>  <!-- end .menu1 --> 
</div>

Any help?

EDIT: Update. Functions page pasted below

<?php
/** Load the Core Files */
require_once( trailingslashit( get_template_directory() ) . 'lib/init.php' );
new Infinity();

/** Do theme setup on the 'after_setup_theme' hook. */
add_action( 'after_setup_theme', 'infinity_theme_setup' );

/** Theme setup function. */
function infinity_theme_setup() {

    /** Add theme support for core framework features. */
    add_theme_support( 'infinity-core-menus', array( 'infinity-primary-menu' ) );
    add_theme_support( 'infinity-core-sidebars', array( 'infinity-primary-sidebar' ) );
    add_theme_support( 'infinity-core-featured-image' );
    add_theme_support( 'infinity-core-custom-header' );

    /** Add theme support for WordPress features. */
    add_theme_support( 'automatic-feed-links' );
    add_theme_support( 'custom-background', array( 'default-color' => 'fafafa' ) );

    /** Set content width. */
    infinity_set_content_width( 600 );

    /** Add custom image sizes. */
    add_action( 'init', 'infinity_add_image_sizes' );   

}

/** Adds custom image sizes */
function infinity_add_image_sizes() {
    add_image_size( 'featured', 200, 200, true );
}
?>

Menu code below

function infinity_register_menus() {

    /** Get theme-supported menus. */
    $menus = get_theme_support( 'infinity-core-menus' );

    /** If there is no array of menus IDs, return. */
    if ( !is_array( $menus[0] ) ) {
        return;
    }

    /* Register the 'primary' menu. */
    if ( in_array( 'infinity-primary-menu', $menus[0] ) ) {
        register_nav_menu( 'infinity-primary-menu', __( 'Infinity Primary Menu', 'infinity' ) );
    }

Related posts

Leave a Reply

1 comment

  1. Adding custom menu position to your wordpress theme is fairly simple.
    This is usually done this way:

    1. Announcing the desired menu positions (in function.php):

    add_action( 'init', 'register_my_menus' );
    
    function register_my_menus() {
        register_nav_menus(
            array(
                'first-menu' => __( 'First Menu' ),
                'second-menu' => __( 'Second Menu' ),
                'third-menu' => __( 'Third Menu' )
            )
        );
    }
    

    .

    2. Embedding them in desired place in your theme:

    <?php wp_nav_menu( array( 'theme_location' => 'first-menu' ) ); ?>
    

    .

    In Your case & since you already have one custom menu position you first need to find in your functions.php where the current menu was defined and add another one as shown in the above example.

    Hope this helps,
    sagive.

    EDITED (REPLACE THE EXISTING CODE IN YOUR MENU CODE):

    function infinity_register_menus() {
    
        /** Get theme-supported menus. */
        $menus = get_theme_support( 'infinity-core-menus' );
    
        /** If there is no array of menus IDs, return. */
        if ( !is_array( $menus[0] ) ) {
            return;
        }
    
        /* Register the 'primary' menu. */
        if ( in_array( 'infinity-primary-menu', $menus[0] ) ) {
            register_nav_menu( 
                array(
                    'infinity-primary-menu' => __( 'Infinity Primary Menu', 'infinity' ),
                    'secondary-menu' => __( 'Secondary Primary Menu', 'infinity' )
                )
            );
        }
    }