Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hard-coding a shortcode as the last menu item…WORKS…question about shortcodes in menu


  • admin25
    Participant

    @admin25

    Hello, I am using the following code to get a shortcode in my menu and it works, the dropdown menu is there.

    I notice that some shortcodes work (execute as a menu item) and some do not.

    e.g the shotcodes for say; contact form 7 work, but, shortcodes that give a list of links say for a blogroll or from Bowe Codes for the list of groups a user belongs to dose not work.

    And this last is what I was hoping to do, add a menu dropdown with the logged in users list of groups they belong to.

    Is it possible to force a shortcode that outputs a list to execute as a menu item?

    Thanks for any help.

    function my_contact_item($items, $args) {
    if( $args->theme_location == 'primary' )
    return $items . '<li class="myclass"><a href="#">My link title</a><ul class="sub-menu"><li><div style="width:350px">' . do_shortcode('[My_Shortcode]') . '</div></li></ul></li>';
    }
    add_filter('wp_nav_menu_items','my_contact_item', 10, 4);
  • The topic ‘Hard-coding a shortcode as the last menu item…WORKS…question about shortcodes in menu’ is closed to new replies.
Skip to toolbar