Hi friends, In the earlier post learned how to create wordpress widgets and in this post I will explain how to execute PHP code in your widgets in WordPress. Recently I have done in my “About The Author” widget in my blog. I have done this for get and display the Author image in the widget.
Follow the below steps to execute PHP code
Open functions.php (Theme Functions) of your activated theme.
Add the below code in that file
$html_php_code = ob_get_contents();
By this we can execute the PHP code in your widget without adding or installing plugins.