Wednesday, 30 July 2014

How to Run php Code in Wordpress Widget

Hi ,
Today we learn How to Run php Code in Wordpress Widget  ?  Normally if you Write php Code  Wordpress Widget , This code will won't Work .So if you want to Support your php code into wordpress text widget . you need to Follow this code paste into your theme function.php File .

add_filter('widget_text', 'enable_php_code', 99);
function enable_php_code ($text) {
if (strpos($text, '
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}

Now you can write you php code into wordpress test widget . try it now and enjoy .