当我激活我的主题时,我需要在wordpress中创建一个导航菜单。
我在主题激活时创建了一些页面,我需要将这些页面添加到导航菜单。
我使用register_nav_menu
创建了菜单,但我无法在此菜单下添加页面。
请帮帮我 此致
答案 0 :(得分:1)
您是否尝试过wp_update_nav_menu_item()函数?
wp_update_nav_menu_item(
$id_of_menu,
0, /* Use 0 to create a new menu item */
array(
'menu-item-title' => 'Title',
'menu-item-classes' => 'title',
'menu_item_url' => 'url',
'menu_item_status' => 'published')
);
那应该为你做的伎俩!有关详细信息,请查看http://www.acousticwebdesign.net/wordpress/how-to-create-wordpress-3-navigation-menus-in-your-theme-or-plugin-code/。
答案 1 :(得分:1)
只需写下你的functions.php //在仪表板后添加Orders作为主菜单。
http://codex.wordpress.org/Function_Reference/add_dashboard_page
function dasboard_sub_menu() {
global $menu;
global $submenu;
$menu[6] = array( __('Orders'), 'read', 'edit.php?post_type=shop_order', '', 'menu-top menu-top-first menu-icon-orders', 'menu-dashboard', 'none' );
$menu[7] = array( __('Catalogue'), 'read', 'edit.php?post_type=product', '', 'menu-top menu-top-first menu-icon-catalogue', 'menu-dashboard', 'none' );
$menu[8] = array( __('Coupons'), 'read', 'edit.php?post_type=shop_coupon', '', 'menu-top menu-top-first menu-icon-coupon', 'menu-dashboard', 'none' );
//$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator1' );
$menu[99] = array( '', 'read', 'separator3', '', 'wp-menu-separator2' );
$menu[56] = array( '', 'read', 'separator4', '', 'wp-menu-separator3' );
$menu[57] = array( '', 'read', 'separator5', '', 'wp-menu-separator4' );
$submenu[ 'index.php' ][1] = array( __('Reports'), 'read', 'admin.php?page=woocommerce_reports' );
}
add_action( 'admin_menu', 'dasboard_sub_menu' );
// To add Submenu Orders under Dashboard Sub Menu
// To add Orders as main menu after dasboard