Have you ever wanted to use PHP in WordPress text widgets? All of us have. Here’s a neat little trick to allow you to insert PHP in WP text widgets. Sure, there are several plugins which allow you to do that. But isn’t it neat to use the default WordPress Text widget and give it the PHP dimension? Copy and paste this into your functions.php file and see the magic happen.
add_filter('widget_text', 'php_text', 99);
function php_text($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}
Now all the text widgets can use PHP code as long as it goes in the <?php and ?> tags .
Source: PHP Text Widget
Join 37,807 others and get free tutorials & tips on design & development using Wordpress on, Thesis & Genesis!
Need help with Wordpress, Thesis or Genesis?
Are you a designer or a developer looking for a hand with Wordpress, Thesis or Genesis? Or perhaps want to save time with a project? Get in touch and let's get the ball rolling! Check out our Thesis development, PSD to Thesis & other services.

{ 2 comments on PHP Text Widget — Allow PHP In WordPress Text Widget… read them below or add one }
Thanks for the tidbit of code. This did the trick for me.
You are awesome… Thanks…