• Skip to main content
  • Skip to footer
  • WordPress Training
  • About
  • My Journal
  • Say Hello

Alison Foxall

WordPress Teacher, Web Developer, Designer, and Inbound Marketer

You are here: Home / How-to / How to use WordPress shortcodes in text widgets

February 26, 2014 By Alison Foxall Leave a Comment

How to use WordPress shortcodes in text widgets

A quick how-to! Today I found that using WordPress shortcodes in text widgets right out of the box didn’t work or render. I was using a custom theme I had made myself, so other themes may already have this feature. In the event your shortcodes are not working in a text widget, simply add this line to your functions.php file of your theme. Make sure that it’s within [php]<?php[/php] and [php]?>[/php] tags.

[php]add_filter(‘widget_text’, ‘do_shortcode’);[/php]

Additionally, if you’d like to render a shortcode in a theme file, use the do_shortcode function. Generall, this is not recommended because it’s not editable by the end user easily.

[php]echo do_shortcode(‘[shortcode_name]’);[/php]

Filed Under: How-to, Web Tricks, WordPress

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer

Address & Contact

 

Email Me

Copyright © 2022 · Alison Foxall