WordPress.org

Forums

[resolved] wp_nav_menu() not customizing output. (10 posts)

  1. SooperGenius
    Member
    Posted 2 years ago #

    Hi. I'm trying to put a fairly standard navigation menu in the header part of my site. I've put the following code in the functions.php file of the theme...

    add_theme_support("nav-menus");
    function custom_navigation_menus() {
        $locations = array(
            'header-menu' => __( 'Main Navigation', 'text_domain' ),
        );
        register_nav_menus( $locations );
    }
    add_action("init", "custom_navigation_menus");

    And I put this code in my header.php file...

    <?php wp_nav_menu(
        array(
            "theme-location"	=> "header-menu",
            "container" 		=> "div",
            "container_class" 	=> "standard-font",
            "container_id" 		=> "header-menu",
            "items_wrap" 		=> "<ul>%3$s</ul>",
            "after" 			=> " | "
        )
    ); ?>

    The menu is showing up just fine but without the customized container_class, container_id, etc. It's spitting out the standard mark-up. Before anyone mentions it, I know I could simply apply CSS to the standard mark-up but I'd like to know what I'm doing wrong here for my own enlightenment.

  2. Yojance Rabelo
    Member
    Posted 2 years ago #

    "theme_location" => "header-menu",
    Notice that I changed - with an underscore on theme location so it reads theme_location.

  3. Jose Castaneda
    THEME COFFEE MONKEY
    Posted 2 years ago #

    Are you using the correct theme location? It should be theme_location and not theme-location. That is what I'm guessing just by looking at the code.

  4. SooperGenius
    Member
    Posted 2 years ago #

    Thanks, guys. You are correct that I had mistyped the "theme_location". However, correcting that problem doesn't actually fix the issue. It still doesn't add the "id" or "class" to the container or anything else. If someone wants, I can put the zip file with the theme somewhere. I'm perfectly willing to let folks look at my code. I just didn't want to clutter the forum with crap-tons of code.

    Andrew

  5. Jam Viet
    Member
    Posted 2 years ago #

    Sometime i have the same mistyping like dash and underscore.

  6. Jose Castaneda
    THEME COFFEE MONKEY
    Posted 2 years ago #

    You can also use gist.github.com if you want.

  7. SooperGenius
    Member
    Posted 2 years ago #

    Gist is quite cool. I've put the relevant code in there, I think. If you need something else put in, let me know.

    https://gist.github.com/AndrewECooper/9970622

    Andrew

  8. Jose Castaneda
    THEME COFFEE MONKEY
    Posted 2 years ago #

    It's the items_wrap that is causing that. You haven't declared the id or the class in the ul. I'm surprised I missed that. Lol.

    and I also commented in your gist. ;)

  9. SooperGenius
    Member
    Posted 2 years ago #

    Thanks for the help guys!

  10. Jose Castaneda
    THEME COFFEE MONKEY
    Posted 2 years ago #

    Of course! Happy to help however we can. :)

Topic Closed

This topic has been closed to new replies.

About this Topic