ThemeShaper Forums » Thematic

[closed]

How to add additional menu?

(8 posts)
  • Started 3 years ago by divago
  • Latest reply from em hr
  • This topic is resolved
  1. divago
    Member

    Hello,

    i am using matteostagi's method for the menu of my child theme (http://www.matteostagi.it/2009/menu-di-navigazione-configurabile-per-thematic).
    Now i am trying to create another little menu above the main one, that i moved upside, but i really don't know how can i do that.
    Sorry but this is my first thematic child template and there is so much to learn...

    Any idea on how this can be solved? Thanks.

    Posted 3 years ago #
  2. Well, I'd start by finding the place where you want to insert the menu. Maybe something like this:

    function secondarymenu() {
         echo 'New Menu Goes Here';
    }
    
    add_action('thematic_header','secondarymenu', 1);

    Where I have 1, you could put 4 or 6 etc, depending on where you want the menu (ie add_action('thematic_header','secondarymenu', 8);) Then update your syntax so it is an actual menu and style it.

    Posted 3 years ago #
  3. while matt's idea is brilliant, it is sort of outdated now that you can build custom menus in WP3.0

    http://forums.themeshaper.com/topic/a-better-way-to-use-the-new-menu-in-wordpress-30-final-version#post-13265

    http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus

    in terms of 2 menus i had this on a test blog that never got finished :

    /* ********************************************** */
    /* MENUS */
    /* ********************************************** */
    
    // We declare that our theme supports wp_nav_menu()
    add_theme_support( 'nav-menus' );
    
    // We Register the a new menu for the theme called "Primary Menu"
    function register_my_menus() {
    	register_nav_menus(
    		array(
    			'primary-menu' => __( 'Primary Menu' ),
    			'secondary-menu' => __( 'Secondary Menu' ),
    		)
    	);
    }
    add_action( 'init', 'register_my_menus' );
    
    // We remove the standard Thematic menu
    function remove_menu() {
    	remove_action('thematic_header','thematic_access',9);
    }
    add_action('init', 'remove_menu');
    
    // We create the new wp_nav_menu called "Primary Menu" in our theme
    function child_access() { ?>
    	<div id="access">
    		<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div><!-- .skip-link -->
    
    			<?php /* Our navigation menu.  If one isn't filled out, wp_nav_menu falls back to wp_page_menu.  The menu assiged to the primary position is the one used.  If none is assigned, the menu with the lowest ID is used.  */ ?>
    			<?php 
    
    			 wp_nav_menu( array(
                              			'theme_location' => 'primary-menu', // we define this as being the previously registered "Primary Menu"
                              			'menu_class' => 'sf-menu', // we assign the sf-menu class to the menu ul so that superfish workds
                              			'container_class' => 'menu', // we assign the menu class to the menu container div so to keep it compatible with the Thematic menu styling
    									//'fallback_cb' => '',
    								));
    
    			?>
    	</div><!-- #access -->
    <?php
    }
    add_action('thematic_aboveheader','child_access');
    
    function secondary_menu() {
    
    if ( has_nav_menu( 'secondary-menu' ) ) { ?>
    
    	<div id="nav-container">
    		<?php wp_nav_menu( array( 'theme_location' => 'secondary-menu',
                              			'menu_class' => 'sf-menu', // we assign the sf-menu class to the menu ul so that superfish workds
                              			'container_class' => 'menu', // we assign the menu class to the menu container div so to keep it compatible with the Thematic menu styling
    		) ); ?>
    
    	</div>
    
    <?php }
    }
    
    add_action('thematic_belowheader','secondary_menu');

    it worked as far as i can recall. but i doubt it is the most elegant code you will ever see. you mileage may definitely vary.

    Posted 3 years ago #
  4. Hi,

    please use:


    add_theme_support( 'menus' );

    instead of:


    add_theme_support( 'nav-menus' );

    This is one of the last minute changes in WP 3.0

    Chris

    Posted 3 years ago #
  5. divago
    Member

    Thank you very much Helga and Chris !!!!!!!
    i'll save your suggestions for some other work..
    I am still using WP2.9.2 and i used something like Devin's method

    [code]
    function secondary_menu() { ?>
    <div id="beforebranding">
    MY LINKS
    </div>
    <?php }
    add_action('thematic_header','secondary_menu', 2);
    [/code]

    bye

    Posted 3 years ago #
  6. Cezar
    Member

    @helga - i think it also requires css changes for top menu to work with sub navigation

    Posted 3 years ago #
  7. @Cezar - i'm not sure what you mean, but if you assign the same css classes used in the default #access menu then it should look and function exactly the same way.

    Posted 3 years ago #
  8. Hi,

    Heads up using add_theme_support in this way is not advised

    ref: http://forums.themeshaper.com/topic/add_theme_supportmenus

    -Gene

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.