Created
May 25, 2015 15:21
-
-
Save 3200creative/2b6fbbb71aa61a2dd984 to your computer and use it in GitHub Desktop.
Custom Menu Directly In WordPress Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* 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