How to enabler shortcode on Customizer Theme Wordpress?

how to enable shortcode as seen in the picture?

i have use do_shortcode() but not work

1 Like

You need to enable shortcodes in text widgets. You can do this by adding this piece of code in your functions.php

add_filter( 'widget_text', 'do_shortcode' );

You can pass every string to do_shortcode() including get_theme_mod() calls.

echo do_shortcode( get_theme_mod( 'theme_setting' ) );

Reference: StackExchange

1 Like

if you can help I placed Where?
whether function.php on a theme or in wp-inludes / function.php?
I try to add dikeduanya error message appears when accessed

The kprtanpabank.com page is not working

kprtanpabank.com is currently Unable to handle this request.

No, you need to add that piece of code in functions.php inside your active theme folder.

For example:
wp-content/themes/your-active-theme/functions.php

Hey,

Thanks for the answer. I have the same problem. I used the piece of code, but that doesn’t work. I think it’s because that the customizer/theme use sanitize_callback, no? How to disable this?

Thanks a lot!

Depending on the theme you are using and the way the customizer fields are created. To test that piece of code please add a shortcode into a Text Widget and see if its working. If yes, then is a problem with the theme customizer option.

Thanks for the answer. Yes, it works with widgets. But not with the customizer. It’s because sanitize_callback I think. :frowning:

Thanks for your help :heart_eyes:

5 Years Old Topic