I'm trying to include a shortcode to an html widget by adding below code to functions.php
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
and to the html widget <script>alert("'" + [user_email] + "'");</script>
but it keeps saying user_email
is not defined.
I'm trying to include a shortcode to an html widget by adding below code to functions.php
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
and to the html widget <script>alert("'" + [user_email] + "'");</script>
but it keeps saying user_email
is not defined.
- edit your question to show us the exact HTML code you use in the widget. – Kaperto Commented Dec 2, 2019 at 12:54
- If the filter didn't work, it would just print the text. But apparently it does work, because you get an error message.The problem seems to be that the shortcode is ill defined. – cjbj Commented Dec 2, 2019 at 15:32
- yes it was. thank you. – Andre S Commented Dec 3, 2019 at 6:51
1 Answer
Reset to default 1First thing you need to do is drag & drop a Text widget to your WordPress sidebar on the Appearance » Widgets screen in your dashboard. After adding the widget, you can simply add your shortcode inside the text edit area of the widget.