Title: Adding shortcode to Plugin
Last modified: August 7, 2017

---

# Adding shortcode to Plugin

 *  Resolved [jamezon](https://wordpress.org/support/users/jamezon/)
 * (@jamezon)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/adding-shortcode-to-plugin/)
 * Hi,
 * It is easy to add shortcode to a text widget by either using a plugin or adding
   the following to the functions file:
 * add_filter( ‘widget_text’, ‘shortcode_unautop’ );
    add_filter(‘widget_text’, ‘
   do_shortcode’);
 * This enables you to use a shortcode such as a date and then displaying a current
   or dynamic date in your widget sidebar.
 * Is there a way to actually enable shortcode execution (specifically for a dynamic
   or current date) for WordPress Popular Posts?
 * The actual shortcode is showing in the side bar and not the date.
 * WordPress does not support shortcodes in widgets or the sidebar as far as I know,
   unless you add a filter.
 * Can anyone help please?
 * Thanks.

Viewing 3 replies - 16 through 18 (of 18 total)

[←](https://wordpress.org/support/topic/adding-shortcode-to-plugin/?output_format=md)
[1](https://wordpress.org/support/topic/adding-shortcode-to-plugin/?output_format=md)
2

 *  Thread Starter [jamezon](https://wordpress.org/support/users/jamezon/)
 * (@jamezon)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/adding-shortcode-to-plugin/page/2/#post-9401214)
 * Thanks Hector,
 * Without your help I would not have been able to solve the problem.
 * I converted the code to a plugin like you suggested and installed everything 
   on a brand new domain. Got all sorts of errors. Then I deactivated the plugin
   and the shortcode worked.
 * After a long investigation, I finally traced the problem to the following:
 * If you enable the Ajaxify widget in the tools section of your plugin, then the
   shortcode will not execute in the sidebar. I had it enabled because of WP Super
   Cache.
 * Thanks again for your help.
 * James
 *  Plugin Author [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * (@hcabrera)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/adding-shortcode-to-plugin/page/2/#post-9401538)
 * Glad to know you got it working 🙂 Will look into the Ajaxify widget issue though,
   that shouldn’t happen (or at least no one had reported anything similar until
   now.)
 *  Thread Starter [jamezon](https://wordpress.org/support/users/jamezon/)
 * (@jamezon)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/adding-shortcode-to-plugin/page/2/#post-9401839)
 * Thanks again Hector.

Viewing 3 replies - 16 through 18 (of 18 total)

[←](https://wordpress.org/support/topic/adding-shortcode-to-plugin/?output_format=md)
[1](https://wordpress.org/support/topic/adding-shortcode-to-plugin/?output_format=md)
2

The topic ‘Adding shortcode to Plugin’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-popular-posts/assets/icon-256x256.png?rev=1232659)
 * [WP Popular Posts](https://wordpress.org/plugins/wordpress-popular-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-popular-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-popular-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-popular-posts/reviews/)

## Tags

 * [do_shortcode](https://wordpress.org/support/topic-tag/do_shortcode/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [wpp_post](https://wordpress.org/support/topic-tag/wpp_post/)

 * 18 replies
 * 2 participants
 * Last reply from: [jamezon](https://wordpress.org/support/users/jamezon/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/adding-shortcode-to-plugin/page/2/#post-9401839)
 * Status: resolved