At some point, you may find yourself wishing you could just drop a line of php code in a widget to post to your sidebar or footer. (The default text widget only accepts HTML code.) It’s not fun to have to keep digging into your core theme files to make a new plugin work, especially if you want to just drop something into your sidebar real quick. This plugin come in handy for times like these. 🙂
In this example, I wanted to place my own code for showing Popular Posts in the sidebar. I didn’t like the way the default Popular Posts Widget displayed the posts. Instead of having to customizing the plugin widget php file, I opted for this widget plugin and dropped the code in.
PHP Code Widget Plugin
This creates a new type of text widget for your sidebar. It’s like the Text widget, but it accept take PHP code as well. Download the PHP Code Widget from the WordPress Plugins Directory. After you install, you’ll find a new “widget” ready to accept your php code.
Wait, you want to place a Shortcode in the widget? You can do that too. View this recent tutorial on how to Allow Shortcodes in Sidebar Widgets.