Allow PHP in WordPress text widgets Trick & Tips

| December 22, 2012

There are many plugin that can execute php code in wordpress widget but If you want to execute php code in your wordpress widget without any plugin help simply follow these instruction.

  • Open your WordPress Dashboard like
  • Then click on Apperance & Click on Editor
  • Then click on functions.php fine on the right hand side & copy and paste in it.
  • Go to WordPress Appearance Widget Section, add some php code or script to text widget and check it.


function php_text($text) {
 if (strpos($text, '<' . '?') !== false) {
 eval('?' . '>' . $text);
 $text = ob_get_contents();
 return $text;
add_filter('widget_text', 'php_text', 99);





Tags: , ,

Category: Wordpress

Leave Your Comments