WordPress.org

Ready to get started?Download WordPress

Forums

wp_nav_menu to output shortcode (2 posts)

  1. Hartech Softworks
    Member
    Posted 1 year ago #

    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.

  2. chrisparksaz
    Member
    Posted 1 year ago #

    Trying to do the same as well. Hope you get an answer....

Topic Closed

This topic has been closed to new replies.

About this Topic