PluginProbe
SpiceBox / 0.3.5
SpiceBox v0.3.5
trunk 0.2.2 0.2.3 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 0.3.8 0.3.9.1 0.3.9.2 0.4 0.5 0.6 0.7 1.0 All 76 releases
spicebox / inc / innofit / default-pages / home-custom-menu.php

home-custom-menu.php in SpiceBox 0.3.5, at inc/innofit/default-pages/home-custom-menu.php

68 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php $run_once = get_option('menu_check');
2 if (!$run_once){
3 //give your menu a name
4 $name = 'primary';
5 //create the menu
6 $menu_id = wp_create_nav_menu($name);
7 //then get the menu object by its name
8 $menu = get_term_by( 'name', $name, 'nav_menu' );
9
10 //then add the actuall link/ menu item and you do this for each item you want to add
11 wp_update_nav_menu_item($menu->term_id, 0, array(
12 'menu-item-title' => __('Home'),
13 'menu-item-url' => '#totop',
14 'menu-item-status' => 'publish',
15 'menu-item-position' => 1,
16 ));
17
18 wp_update_nav_menu_item($menu->term_id, 0, array(
19 'menu-item-title' => __('Service'),
20 'menu-item-url' => '#services',
21 'menu-item-status' => 'publish',
22 'menu-item-position' => 2,
23 ));
24
25 wp_update_nav_menu_item($menu->term_id, 0, array(
26 'menu-item-title' => __('About'),
27 'menu-item-url' => '#about',
28 'menu-item-status' => 'publish',
29 'menu-item-position' => 3,
30 ));
31
32 wp_update_nav_menu_item($menu->term_id, 0, array(
33 'menu-item-title' => __('Team'),
34 'menu-item-url' => '#team',
35 'menu-item-status' => 'publish',
36 'menu-item-position' => 4,
37 ));
38
39 wp_update_nav_menu_item($menu->term_id, 0, array(
40 'menu-item-title' => __('Blog'),
41 'menu-item-url' => '#blog',
42 'menu-item-status' => 'publish',
43 'menu-item-position' => 5,
44 ));
45
46 wp_update_nav_menu_item($menu->term_id, 0, array(
47 'menu-item-title' => __('Contact'),
48 'menu-item-url' => '#contact',
49 'menu-item-status' => 'publish',
50 'menu-item-position' => 6,
51 ));
52
53 wp_update_nav_menu_item($menu->term_id, 0, array(
54 'menu-item-title' => __('Callout'),
55 'menu-item-url' => '#call-to-action',
56 'menu-item-status' => 'publish',
57 'menu-item-position' => 7,
58 ));
59
60
61 //then you set the wanted theme location
62 $locations = get_theme_mod('nav_menu_locations');
63 $locations['main-menu'] = $menu->term_id;
64 set_theme_mod( 'nav_menu_locations', $locations );
65
66 // then update the menu_check option to make sure this code only runs once
67 update_option('menu_check', true);
68 } ?>