Tip: Use a WordPress shortcode outside the loop

Remi | June 8, 2012 | in Tips

Hey! Today i have a quick tip tip for you! How many times did you try to insert a shortcode outside the loop? In a text widget for example, in a menu item, in your author biographical information or anywhere else… to do that, there’s a really simple function called: do_shortcode(). Just use it this way:

The author

About the author Remi: Hey! My name is Rémi Corson, i'm a WordPress Expert Developer, i create high level themes and plugins, and i provide free stuff every week on this website!

One comment

  1. Robert

    I haven’t tried this yet, but in you said “in a menu item”. So do you mean using this I can use a shortcode as a link in the built-in WP menu functionality? I want to use a shortcode from a plugin that creates a modal login window and I would love to have a link in my nav menu that says “Login” and then calls that modal window using a shortcode. The plugin has the shortcode, but I can’t use it in the menu since WP removes the square brackets and prepends an http:// on it.

Leave a reply