Currently I'm making this menu: (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'));
}
When I activate my theme, what I'm looking to do is:
(source: cubeupload.com)
Selecting the 'Primary Menu' box automatically so when I start this theme I create a menu and make it the primary menu.
How does one do this?
You can set the theme_location
of the menu programmatically with:
$locations = get_theme_mod('nav_menu_locations');
$locations['primary-menu'] = $term_id_of_menu;
set_theme_mod( 'nav_menu_locations', $locations );
Add this to your functions.php
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With