WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Theme Menu Almost there Help Please (3 posts)

  1. cicakchanson
    Member
    Posted 1 year ago #

    Hi everyone and thanks for helping me! I'm trying to add a second menu to my theme but I've ran into an issue that I'm sure is something fairly easy for someone that has a better understanding of PHP than me.

    Anyhow, I have successfully added a second menu in the sense that i have the option to build one under 'Appearance/menus' in the back end of the site and it clearly states that my theme now supports 2 menus whereas before it only supported 1. I also have a secondary menu appearing on the front end of my site HERE

    I realize that the new menu is completely unstyled and there is another tab style menu that is currently floating off in space... In short, the formatting of my site is currently a mess but please try to ignore all that...

    My concern is that the new secondary menu I've created is listing every page on the site as found under 'Pages/All Pages' and in the order currently found there instead of displaying what is currently supposed to be in the new secondary menu according to the one I created under 'Appearance/Menus.'

    My suspicion is that the PHP I've put in the functions.php file is somehow not relating to the code I've placed in the header.php file. Please check to see if the code I've placed in these two files is somehow unrelated (as I suspect) which is consequently giving me the option to build a secondary menu in the backend under 'Appearance Menus' but what is currently being displayed in the frontend is actually not the same menu .

    by the way, I'm using custom childtheme based on a theme called Skeleton by Simplethemes

    Here is the code I've placed in the functions.php file

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

    Here is the code that is in the header.php file
    <?php wp_nav_menu( 'sort_column=menu_order&menu_class=row sixteen columns&theme_location=second-menu' ); ?>

    Again, thanks for the help!

  2. Andrei Olsen
    Member
    Posted 1 year ago #

    Shouldn't theme_location refer to the menu you register?

    Rename Secondary to second-menu in register_nav_menus, or the other way around.

  3. cicakchanson
    Member
    Posted 1 year ago #

    Absolutely Andrei,

    I found the issue. Of course the moment you ask it comes to you. Turns out I was right about suspecting where the problem was. My code in the header was faulty. It should have been this:

    <?php wp_nav_menu( 'sort_column=menu_order&menu_class=row sixteen columns&theme_location=Secondary' ); ?>

    Duh!

    Well at least it will help someone else some day.

Topic Closed

This topic has been closed to new replies.

About this Topic