Search code examples
phpshortcodewordpress

WordPress Widgets using PHP or Shortcodes


I created a header area thats basically 6 widgets, 3 on 2 rows. However, I would like to place into one of the widgets some PHP or a shortcode. The widget will only read HTML as far as I know. Is there a way perhaps in the functions.php to allow shortcodes or PHP to be read and executed as well?


Solution

  • To enable shortcode on text widget, just add filter in your theme functions.php

    add_filter( 'widget_text', 'do_shortcode' );