WordPress.org

Ready to get started?Download WordPress

Forums

Theme Nav (4 posts)

  1. Danny159
    Member
    Posted 2 years ago #

    Hey guys,

    I have the following HTML static code:

    <div class="Alignment">
        <div class="MenuItem First"><a href="?view=home" class="Selected">Link</a></div>
        <div class="MenuItem"><a href="?view=about" >Link</a></div>
        <div class="MenuItem"><a href="?view=gallery" >Link</a></div>
        <div class="MenuFooter"></div>
    </div>

    And I want to turn this into a wordpress driven menu...
    I have the menu set-up but I cant get the settings right to do that I need too about?

    <?php
    wp_nav_menu(array(
    	'theme_location' => 'main',
    	'menu_class' => 'MenuItem'
    ));
    ?>

    Can anyone please help me :)
    Dan

  2. egado
    Member
    Posted 2 years ago #

    1. Register the custom menu in your functions.php

    // Custum Menus
    add_action('init', 'register_custom_menu');
    
    function register_custom_menu() {
    register_nav_menu('my-menu', 'My Menu');
    }

    2. Paste that (maybe with some little changes for the menu css class ;) in your template

    <?php wp_nav_menu( array( 'theme_location' => 'my-menu', 'container' => 'my-menu', 'menu_class'  => 'my-menu-css-class' ) ); ?>

    3. Go to your admin area: Appearance > Menus and set up

    Does that work for you?

  3. Danny159
    Member
    Posted 2 years ago #

    I have got it all working, I just need some help with the wp_nav_menu() function to get it to make the code I have above?

    As what I have now is as following:
    <?php wp_nav_menu( array( 'theme_location' => 'main', 'container' => 'Alignment', 'menu_class' => 'MenuItem' ) ); ?>

    But I get this from that.... not like the static code above....

    <div class="MenuItem">
        <ul>
            <li class="page_item page-item-10 current_page_item"><a href="#">Link</a></li>
            <li class="page_item page-item-20"><a href="#">Link</a></li>
            <li class="page_item page-item-18"><a href="#">Link</a></li>
            <li class="page_item page-item-22"><a href="#">Link</a></li>
        </ul>
    </div>

    Dan

  4. egado
    Member
    Posted 2 years ago #

    Oh ok... guess you wont get this 1:1 but have a closer look to the "items_wrap" option: http://codex.wordpress.org/Function_Reference/wp_nav_menu

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.