Skip to content

Instantly share code, notes, and snippets.

@bryanmonzon
Last active August 29, 2015 14:06
Show Gist options
  • Save bryanmonzon/77c662d31ad586bc299a to your computer and use it in GitHub Desktop.
Save bryanmonzon/77c662d31ad586bc299a to your computer and use it in GitHub Desktop.
<?php
if( is_page( 'page-slug-or-ID-here') ){
wp_nav_menu( 'menu-id-here')
}elseif( is_page('another-slug')) {
wp_nav_menu( 'another-menu-id-here')
}
//Another solution is to register your menus with page slugs and then output a menu
global $post; //set the global $post variable
$slug = get_post( $post )->post_name; //set $slug to 'post_name' value irom the object
wp_nav_menu( $slug );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment