Word Press default widget does not allow you to use php code. You can do this by simply editing template files but this is not overall solution. By doing this you are loosing beauty of widget drag and drop functionality. The Samsarin PHP Widget available as plug-in that allow user to create new widget and add php code inline with text.
Installation & Usage
- Go to the Samsarin PHP Widget website.
- Download and Extract the zip file in wordpress plugins directory.
- Enable the Samsarin PHP Widget from Admin Panel.
- In your admin console, go to Presentation, and then go to Sidebar Widgets
- Create number of PHP Widgets you are required to add.
- Drag one of the available Samsarin PHP Widgets to your sidebar.
- Click on the widget button add title and php code.
- All you have done..