How to allow custom shortcodes in custom widgets or in widgets in wordpress

For allow shortcodes in widgets we need to add 2 filters for render shortcodes.

1). Add below filter for remove auto p tag for widget area.. So our shortcode output will not wrapped by p tag
  add_filter( 'widget_text', 'shortcode_unautop'); 

2) .Below filter will allow widget text to rendor shortcode
add_filter( 'widget_text', 'do_shortcode', 11);

Comments

Popular posts from this blog

How to add a custom sorting or order by option on category archive or product archive page in woocommerce wordpress

How to create a custom wp_list_table and bulk action in wordpress

How to add image option in nav menu in wordpress