WordPress.org

Ready to get started?Download WordPress

Forums

how to insert shortcode into Nav menu? (1 post)

  1. capson
    Member
    Posted 1 year ago #

    Hello, I have made a menu item with the following code.

    The menu item shows up but the shortcode output is not there.

    Is there something I can add or a different method that will do this.

    //--Nav Menu
    function add_profile_link_to_nav(){
     if ( is_user_logged_in() ) { ?> 
    
    <ul>
      <li class="menu-item"id="one"> <a href="http://example.com/">Home</a>
        <ul class="sub-menu">
              <li class="menu-item"><?php echo custom_execute_shortcode(); ?> </li>
        </ul>
     </li>
    </ul>    <!--end menu--->
    <?php }
    }
    add_action( "wp_nav_items","add_profile_link_to_nav" );
    
    function custom_execute_shortcode() {
     $myfunction= '[bc_user_groups amount="20"]';
     $myfunction_parsed = do_shortcode($myfunction);
     return $myfunction_parsed;
    }

    I have also added
    add_filter('bp_menu', 'do_shortcode', 7);
    in hopes this might help.

    Thanks for any help or insight.

Topic Closed

This topic has been closed to new replies.

About this Topic