Tips and tricks
How to assign a menu to a wordpress theme location from php
This is the code
$locations = get_theme_mod( 'nav_menu_locations' );
if(!empty($locations))
{
foreach($locations as $locationId => $menuValue)
{
if($locationId=='primary'){
if(isset($menu_id))
{
$locations[$locationId] = $menu_id;
set_theme_mod('nav_menu_locations', $locations);
}
}
}
}
replace ‘primary’ with the location of your theme, for the menu.
Recent Comments
- admin on Vimeo Thumbnail Generator
- Robert Moeck on Vimeo Thumbnail Generator
- Rainer on Vimeo Thumbnail Generator
- Video Gallery WordPress Plugin /w YouTube, Vimeo, Facebook pages | Berita Online on Vimeo Thumbnail Generator
- Use Browserify Globally as Watcher in PhpStorm [ add Babelify ] – Digital Zoom Studio on Setup a .babelrc in your user directory