Widget
How to PHP code support in WordPress widget
Normally PHP code not working in WordPress default widget. But when we write a function for supporting PHP code in widget, than it is working good.
On this tune I am going describe “How to PHP code support in WordPress widget”. For supporting PHP code in WordPress widget you need to take this function in your theme functions.php
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 trying test in a text on WordPress widget write “<?php echo “Test PHP code in widget”?>”
Hopefully it is working properly.
Comments are closed