• Hi forumers,

    For a specific project, I am trying to output shortcode via the wp_nav_menu.

    <?php
    
    $defaults = array(
    	'theme_location'  => '',
    	'menu'            => '',
    	'container'       => 'div',
    	'container_class' => '',
    	'container_id'    => '',
    	'menu_class'      => 'menu',
    	'menu_id'         => '',
    	'echo'            => true,
    	'fallback_cb'     => 'wp_page_menu',
    	'before'          => '',
    	'after'           => '',
    	'link_before'     => '',
    	'link_after'      => '',
    	'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    	'depth'           => 0,
    	'walker'          => ''
    );
    
    wp_nav_menu( $defaults );
    
    ?>

    Above is the default wp_nav_menu

    The output that is required would be:
    [button text="%3$s" link="MenuItemLink" size="large" style="default" target="_self"]

    I will have to remove the container as WP only allows ul or div. But how do I go about adding the link for that specific menu item ?

    Any help is much appreciated.

    Thanks.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_nav_menu to output shortcode’ is closed to new replies.