Last Updated: February 25, 2016
·
282
· alejandrogm

Register menu, create items and assign menu to location

//Register menu function
if ( functionexists( 'addthemesupport' ) )
add
themesupport ('nav-menus');
add
action('init', 'registrarnavegacion' );
function registrar
navegacion() {
registernavmenus (array(
'header' => __('Menu Header', 'storelicious' ),
));
}

function createmenu() {
$menu
id = wpcreatenavmenu('Top Menu');
$menu = array(
'menu-item-type' => 'custom',
'menu-item-url' => get
homeurl('/'),
'menu-item-title' => 'Home',
'menu-item-status' => 'publish',
);
wp
updatenavmenuitem( $menuid, 0, $menu );
$locations = getthememod('navmenulocations');
$locations['header'] = $menuid ;
set
thememod('navmenulocations', $locations);
}
if( ! has
navmenu('header') ){ addaction('init', 'create_menu' ); }