Title: adding [shortcode] to menu-item
Last modified: December 15, 2019

---

# adding [shortcode] to menu-item

 *  Resolved [Shane Taylor](https://wordpress.org/support/users/propertunity/)
 * (@propertunity)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-shortcode-to-menu-item/)
 * I added the following to functions.php which lets me use shortcodes in menus 
   just fine..
 * `add_filter('wp_nav_menu_items', 'do_shortcode');`
 * My issue is that when I add a [shortcode] to the navigation label of a specific
   menu item, it doesn’t put the [shortcode] to the right of the menu-item like 
   I assumed it would, but instead is placing the shortcode outside of the entire
   menu-header_menu (all menu items)
 * Does anyone know what I am missing? Thanks in advance..

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-shortcode-to-menu-item/#post-12240821)
 * Did you write the shortcode handler?
    A common mistake with shortcode handlers
   is that they echo the result instead of returning it. That means it ends up in
   a strange place. The handler should always return a string, with no echo statements.
   Also, I didn’t check, but is that the correct filter to use?
 *  Thread Starter [Shane Taylor](https://wordpress.org/support/users/propertunity/)
 * (@propertunity)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/adding-shortcode-to-menu-item/#post-12240841)
 * omg yes I was using ‘echo’ instead of ‘return’
 * and yes that filter is what I need for the individual menu-item. At least its
   working for me..
 * that fixed it though. thank you 🙂
    -  This reply was modified 6 years, 5 months ago by [Shane Taylor](https://wordpress.org/support/users/propertunity/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘adding [shortcode] to menu-item’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [Shane Taylor](https://wordpress.org/support/users/propertunity/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/adding-shortcode-to-menu-item/#post-12240841)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
