Skip to content

Instantly share code, notes, and snippets.

@WordBits
Created September 14, 2018 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WordBits/2f937646260116f8b5ee7b7f10c2d8e9 to your computer and use it in GitHub Desktop.
Save WordBits/2f937646260116f8b5ee7b7f10c2d8e9 to your computer and use it in GitHub Desktop.
Displays a WordPress navigation menu as a simple bullet point list. Useful for automating a sitemap page or injecting into the footer. Usage: [rtpmenu name="somemenuname"] [rtpmenu name="somemenuname" menu_class="acustomclassforstyling"]
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/rtp-theme-cleaner/
// Created by: Matthew Harris
?>
<?php
function rtp_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'menu' => null, 'menu_class' => 'rtpmenushortcode' ), $atts));
return wp_nav_menu(
array(
'menu_class' => $menu_class,
'menu' => $menu,
'echo' => false
)
);
}
add_shortcode('rtpmenu', 'rtp_menu_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment