<?php
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');
/*
Shortcode in post (to display main menu) :
[menu name="main-menu"]
*/
?>
Create a shortcode to display menu in Wordpress.
Add code in function.php
source : http://stephanieleary.com/2010/07/call-a-navigation-menu-using-a-shortcode/
Add code in function.php
source : http://stephanieleary.com/2010/07/call-a-navigation-menu-using-a-shortcode/
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.