Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

<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' ) );
    }
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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' )
            )
        );
    }
}
share|improve this answer
    
See my update above. I have posted the functions.php –  Mucker Oct 3 '12 at 6:22
    
The file that deals with menus isnt being included so it is probebaly hooked in some othere file. can you pastebin this file lib/init.php ?? –  Sagive SEO Oct 3 '12 at 6:36
    
cool, I see where you are going now. I opened the init file and found it referenced a menu.php file. After opening this I found how it was registering the menus. Code is pasted above. Can you ammend the code to add the second menu please? –  Mucker Oct 3 '12 at 6:50
    
This requires some testing since this is not the default structure... are you sure you dont have a way to create a new menu position in the backend? anyhow i have added a testing code... try it and let me know the result. –  Sagive SEO Oct 3 '12 at 6:55
    
that didn't do anything at all. I don't care if there is another method, I just need to add a second many which displays pages (not posts). If you can think of another way that will be fine. –  Mucker Oct 3 '12 at 7:10
show 8 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.