开发者

How to add a new header menu in wordpress?

开发者 https://www.devze.com 2023-01-12 10:13 出处:网络
How to add a new header menu in开发者_运维百科 wordpress?You may add a function to wordpress (well anywhere in your theme) using the wp_nav_menu(). This requires that you add the code below to your fu

How to add a new header menu in开发者_运维百科 wordpress?


You may add a function to wordpress (well anywhere in your theme) using the wp_nav_menu(). This requires that you add the code below to your functions.php file (if you do not have one in your theme directory then create one):

add_action( 'init', 'register_my_menus' );
    function register_my_menus() {
        register_nav_menus(
            array(
            'menu-1' => __( 'Top menu' ),
            'menu-2' => __( 'Bottom menu' )
            )
        );
    }

Change the "Top menu" and "Bottom menu" to what ever you want the names to be. Basically you are just telling wordpress (wp 3.+) to make reservations for these menu in your theme. If you want more you just need to define the names in a new line. Save that.

That done you will need to add the menu in your site template. Usually I define the arguments first before I call the wp_nav_menu() function. Read up on the arguments here http://codex.wordpress.org/Function_Reference/wp_nav_menu

Hope that helps.


You can manage the menus in your WordPress dashboard under "Appearance => Menus". Here is a tutorial: http://en.support.wordpress.com/menus/

0

精彩评论

暂无评论...
验证码 换一张
取 消