在WordPress主题中自定义菜单

1. 首先在主题的functions.php中注册菜单:

register_nav_menus(array(
'primary_nav' => 'Primary Navigation',
'secondary_nav' => 'Primary Navigation'
));

2. 在后台的 Appearance -> Menus 中设置菜单项。

3. 在主题中显示菜单:

wp_nav_menu( array('menu_class' => 'primary_nav', 'theme_location' =>'primary_nav') );

wp_nav_menu(); 函数支持丰富的参数,详情参考官方文档:
http://codex.wordpress.org/Function_Reference/wp_nav_menu

TrackBack: http://mimiz.cn/index.php/wordpress/custom-menu-in-wordpress-theme/trackback/

Leave a Reply !

^_^您敢留下回复吗?