By default, WordPress shortcodes do not work within Text widgets. If you need this functionality, it is quite easy to accomplish, simply follow the steps below.
Using Shortcodes in a WordPress Text Widget
- Log into your WordPress Dashboard
- Under “Appearance” click “Editor”
- In the list of files on the right of the page, click “functions.php”
- At the bottom of the functions.php file, add the following code:add_filter( ‘widget_text’, ‘shortcode_unautop’);
add_filter( ‘widget_text’, ‘do_shortcode’); - Click “Update File” and your shortcodes should now work in your Text widgets!
Before: | After: |
Changes made to these files may get overwritten after theme updates. It is always recommended to make these kinds of modifications in a child theme.
Looking for more guides? We have over 400 WordPress How To Articles to help you!
hey!i’m using genesis framework with ‘genesis sample develop’ child theme. The problem i am getting is that, this theme is not rendering any shortcodes and html in text widget even after i includingadd_filter( ‘widget_text’, ‘shortcode_unautop’); add_filter( ‘widget_text’, ‘do_shortcode’, 11);to my child theme’s ‘function.php’ file. Please help me out……Thanku
You’ll want to make sure you are adding the code to the functions file created for the child theme instead of the parent theme. Otherwise, I would suggest contacting Genesis to see if they have a suggestion.
Hey Guys,
I’ve changed my functions.php file to allow me to post shortcode to a text widget. My only problem now is that every text widget is showing this shortcode on my page. I’m specifically refering to using a table shortcode.
Please help I’m new to all of this
I was not able to replicate that behavior using the WordPress twenty ten theme. It’s possible there could be a theme or plugin conflict in your installation.
Huge, HUGE THANK YOU ! You saved me, you really did. Thanks a lot !
Thanks for your work!
In my theme I have an area in the top bar where I can add text only in the customization. Is it possible to insert a shortcode there?
I use MaxStore in WordPress with Woocommerce.
Thank you!
Hello Apfelsinchen,
Thanks for the question about the shortcodes in your theme. Typically, shortcodes are only usable in the posts/pages section of WordPress. If you need more information on the customization options for your theme you will need to consult with the theme developer.
If you have any further questions or comments, please let us know.
Regards,
Arnel C.
Hi Sir,
its doesn’t work for me
i am using dream theme 7.2
Plz help
Thnks
Hello Ricky,
What happens when you add the code to your functions.php file? You may need to contact theme forest to see if they have another method for their themes.
Best Regards,
TJ Edens
function hs_shortcode()
{
ob_start();
hs_booking_calender();
return ob_get_clean();
}
add_shortcode(‘hs_calender_shortcode’,’hs_shortcode’);
hi this is my shortcode function now i have to display shortcode after the plugin content
To clarify, are you referring to showing the shortcode content at the end of the post content?
Hi i create a plugin i am getting shortcode also but i have to display shortcode after the plugin content
Hello dileep,
Thank you for contacting us. We are happy to help, but I am not sure what you are asking.
Please provide more information, so we can better assist you.
Thank you,
John-Paul
It’s working…Thank you very much
Do you have the same code for excerpt text area
thnx
Hello Boris,
Thank you for your question. I found a similar question in the Official WordPress forums, where they present several ways to enable shortcodes in excerpts.
If you have any further questions, feel free to post them below.
Thank you,
-John-Paul
i used LPN theme for wordpress … and the latest version of wordpress .. and the shortcode is [indeedsearchform] … anyways i found solution .. the shortcode works on pages, so i make a page and run this shortcode on that page and than parse it to the index page …
It does’t work for me !!! 🙁
Hello Husnain,
Sorry to hear you tried it and it did not work. What theme are you using? What version of WordPress are you using? Which shortcode did you test with to see if it worked?
Kindest Regards,
Scott M
wow!!!!!! you are awesome dude!!!
this is what I’ve looking for!!
Hello Dimas,
Thank you! We are glad to help!
Kindest Regards,
Scott M
How can I enable contact form shortcode in HTML area( Where only allow html tag ) .
[contact-form-7 id=”2358″ title=”Contact Form 1″]
If it’s an HTML-only area, shortcodes cannot be added. You would need to use a normal location or create the form using HTML instead.