Post Tags

WordPress

Pretty posts

Today i will show you how to support php to WordPress widget area. PHP allowed means, In our WordPress widget section there are text widget which only support HTML(Default). PHP does not support. There are many plugins to support php. But today we will learn how to do php allow in your site without plugin. It's very simple, just paste code.

First go to you theme Appearance>Edit then open function.php file. Then paste following code before ?> tag. If this tag is not there, then just paste the code at the end.

function execute_php($html){
     if(strpos($html,"<"."?php")!==false){
          ob_start();
          eval("?".">".$html);
          $html=ob_get_contents();
          ob_end_clean();
     }
     return $html;
}

add_filter('widget_text','execute_php',100);