WordPress 3.0很大的一個特點就是加入了自定義菜單功能,實現了對菜單的可視化調整操作。自定義菜單中可以添加自定義鏈接,頁面或者分類,而且可以對鏈接進行可視化排序,這樣我們就不用再為菜單的排序問題煩惱了,想要什么樣的菜單,只要主題支持,自己就可以DIY啦。
1)使主題支持自定義菜單
在主題的function.php中加入:
if(function_exists(‘register_nav_menus’)){
register_nav_menus( array(
‘primary‘ => __( ‘Primary Navigation‘, ‘twentyten‘ ),
‘second‘ => __( ‘second Navigation‘, ‘twentyten‘ ),
) );
}
傳送門:register_nav_menus函數說明
2)調用自定義菜單
<?php wp_nav_menu( array( ‘container_class’ => ‘menu-header’, ‘theme_location’ => ‘primary‘ ) ); ?>
<?php wp_nav_menu( array( ‘container_class’ => ‘menu-header’, ‘theme_location’ => ‘second‘ ) ); ?>
傳送門:wp_nav_menu函數說明
3)wiget支持
在主題的wigets菜單中有個Custome Menu ,可以添加到邊欄
4)調整菜單順序