Adding PHP Code to your widgets

UPDATE:: Please use another plug-in as this plug-in does not work anymore. Post Archived.

I have been browsing some sites and I found this nice plug-in for wordpress. As you can see, if you wordpress theme (layout) is widget ready, you can easily drag and drop widgets in it. Some of the widgets that you can include are “text widgets” and “rss widgets”. I tried to use a text widget to show the top commentators for this blog but it does not work (the php code is shown as text). So what I did was to manually edit the sidebar.php file, which is the code for the sidebar where the widgets resides.

A disadvantage to manually editing the file is that it only applies to that theme where you edited the file. If you change your theme, then that code you added will not show on the new theme. However, it all changed when I found this plug-in. It allows you to add PHP code to your widgets. It’s called the Samsarin PHP Widget plug-in.

Note that this is different from adding PHP code to your posts. Here are some pictures for you to see it in action.

Before, this is what I did. Manual editing on the theme itself.

But now, look at the ease of doing it through widgets! Oh yeah this is so easy!

How many Php Widgets would you like?

You can now write your PHP code here

The result. It is not a 100% perfect copy but it’s enough for me. hehe