您还可以钩住菜单中的项目:
wp包括/导航菜单模板。php
/**
* Filters the HTML list content for navigation menus.
*
* @since 3.0.0
*
* @see wp_nav_menu()
*
* @param string $items The HTML list content for the menu items.
* @param stdClass $args An object containing wp_nav_menu() arguments.
*/
$items = apply_filters( \'wp_nav_menu_items\', $items, $args );
在导航开始处添加自定义项的示例:
function add_custom_item( $items, $args ) {
$custom_item = "<a href=\'".get_home_url()."\' class=\'intranet\'>H</a>";
return $custom_item . $items;
}
add_filter( \'wp_nav_menu_items\', \'add_custom_item\', 10, 2 );