目前我正在制作这个菜单:(Functions.php)
$menuname = 'Top Menu';
$menu_exists = wp_get_nav_menu_object( $menuname );
if( !$menu_exists){
$menu_id = wp_create_nav_menu($menuname);
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Programme'),
'menu-item-classes' => 'programme',
'menu-item-url' => home_url( '/programme/' ),
'menu-item-status' => 'publish'));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Speakers'),
'menu-item-classes' => 'speakers',
'menu-item-url' => home_url( '/speakers/' ),
'menu-item-status' => 'publish'));
}
当我激活我的主题时,我想做的是:(
来源:cubeupload.com)
自动选择“主菜单”框,因此当我启动此主题时,我会创建一个菜单并将其设为主菜单。
如何做到这一点?