Skip to content

Instantly share code, notes, and snippets.

@3200creative
Created May 25, 2015 15:21
Show Gist options
  • Save 3200creative/2b6fbbb71aa61a2dd984 to your computer and use it in GitHub Desktop.
Save 3200creative/2b6fbbb71aa61a2dd984 to your computer and use it in GitHub Desktop.
Custom Menu Directly In WordPress Post
//* Use with shortcode: [menu name=”sitemap”]
add_action( 'init', 'my_custom_menus' );
function my_custom_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __( 'Secondary Menu' ),
'footer-left' => __( 'Footer Left' ),
'footer-right' => __( 'Footer Right' ),
'sitemap' => __( 'Sitemap' )
)
);
}
function print_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
}
add_shortcode('menu', 'print_menu_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment