Nick Shaw

Set WordPress custom menu per page/post using a custom field

Add this to your template where you want the menu to appear

<?php
$menu_slug = get_post_meta($post->ID,'menu',true);
if(is_nav_menu($menu_slug)) {
	wp_nav_menu(array(
		'menu' => $menu_slug
	));
}
?>

Within each post or page add the custom field menu and set the value to the same as the name of the custom menu you want to appear.

Exit mobile version