Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shortcode to display WordPress Menu
* Shortcode to display a WordPress menu
function theme_slug_menu_shortcode( $atts ) {
// Get Shortcode Parameters.
$menu = shortcode_atts( array(
'slug' => '',
), $atts );
// Return Custom Menu.
return wp_nav_menu( array(
'menu' => $menu['slug'],
'menu_class' => 'artikelserie',
'echo' => false,
'items_wrap' => '<ol id="%1$s" class="%2$s">%3$s</ol>',
) );
add_shortcode( 'custom_menu', 'theme_slug_menu_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.