November
2006
Widgetize Anything
There are many Wordpress plugins that should be converted into sidebar widgets, made compatible with the Automattic Widget Plugin, but, for whatever reason, have not yet been converted. Wouldn’t it be nice if there were a generic way to call other plugins from within a sidebar widget? Now there is! Introducing…. Widgetize Anything!
Basically, it works just like the built-in text widgets, except that it allows you to put in PHP code into the body of the widget.
Features
- Create any number of Widgetize Anything widgets
- Paste PHP code directly into the widgets in the widget admin
- Built in optional “Title” property.
Requirements
- A WordPress Blog
- Wordpress 2.2 or greater -OR- the Automattic Widget Plugin
Installation
- Download the plugin here: widgetize-anything.tar.gz (2.3 kB)
- Unzip the plugin into your /wp-content/plugins directory.
- Activate the plugin in your WordPress admin.
- Choose how many Widgetize Anything widgets you want under Options –> Widgetize Anything (see screenshots)
- Enter the desired PHP code into the widget on the Sidebar Widgets page in your WordPress admin (see screenshots).
- Drag the widget onto the sidebar where you want it on the Sidebar Widgets page in your WordPress admin.
Screenshots
The options screen
The simplest example: Hello World
Calling the WP-PostRatings plugin to display the highest-rated posts.
Troubleshooting
It’s important to understand that the code that you put into your widget must be valid PHP code. You may not open or close PHP blocks with “< ?php" or "?>“, nor can you place straight HTML code into the widget content. You have to echo out all the HTML code that you want to show up on your page.
Change History
| 1.2 | 2007-06-25 | Fixed a bug caused by Wordpress 2.2.1. They changed the way widgets are registered once again. |
| 1.1 | 2007-05-17 | Fixed a bug caused by Wordpress 2.2. For 2.2, they incorporated the sidebar widgets plugin into the main codebase, and a few things changed. |
| 1.0 | 2006-10-24 | Original version |
Questions and Comments
You may leave questions and comments on this blog, or email them directly to me at erikwordpressplugins -at- gmail.

(41 votes, average: 4.71 out of 5)
Erik R.



[...] I haven’t really gotten into the whole Widgets thing (please don’t burn me at the stake), but I have been excited at the idea of Widgets. The thing that is holding me back is that I would want just about everything to be a widget, and now it seems for the most part you can, thanks to Erik’s Widgetize Anything plug-in. There are many Wordpress plugins that should be converted into sidebar widgets, made compatible with the Automattic Widget Plugin, but, for whatever reason, have not yet been converted. Wouldn’t it be nice if there were a generic way to call other plugins from within a sidebar widget? Now there is! Introducing…. Widgetize Anything! [...]
[...] Get it here. [...]
[...] I had meaning to build a widgetizer – something that could widgetize any plugin for Wordpress. But Erik Rasmussen has beat me to it (via Blogging Pro). It might look like just another text widget, but it executes the PHP code typed within it. Wordpress introduced widgets in its recent versions, but not all plugins were widgetized creating problems for users. I had widgetized the Random Quote plugin and wanted to widgetize some more. The difference between what I had thought and this widgetizer is that this will not be able to customize plugin options through the widget GUI. I wonder if this can be built on it! [...]
[...] Sedikit kan persyaratannya? Dan simple pula dalam pemenuhannya.. Plugin ini sendiri sih benernya fungsinya merubah script ato code (PHP) yang kita masukkan menjadi module widget, sehingga bisa dengan mudah kita drag and drop di sidebar blog kita. Seperti kita tau bahwa module Text yang ada di ‘sidebar widget plugin’ tidak bisa digunakan untuk code PHP, dengan plugin ini hal itu sudah bisa diatasi. Untuk lebih jelasnya sih silakan liat di plugin page-nya.. selamat mencoba Filed under blogthing. | Tags: code, PHP, plugin, script, widget. var blogTool = “WordPress”; var blogURL = “http://i-bebek.net”; var blogTitle = “Just Ducky”; var postURL = “http://i-bebek.net/index.php/2006/12/01/code-widgetizer/”; var postTitle = “Code Widgetizer”; var commentAuthorFieldName = “author”; var commentAuthorLoggedIn = false; var commentFormID = “commentform”; var commentTextFieldName = “comment”; var commentButtonName = “submit”; [...]
[...] Widgetize Anything,现在兼容Widget的插件已经越来越多,但是仍有部分优秀的插件并没有针对Widget做过修改,本插件就是让它们能更好的和现有Widget系统兼容。 上传激活,在Widget中使用Widgetize Anything,在相应对话框中加入其它插件的输出语句。 Tag: widget [...]
[...] spostare tutto lo spaghetti php della template all’interno di plugin e widget –> rivalidare XHTML [...]
[...] December 28, 2006Plugin: Widgetize Anything This plugin widgetizes any blog regardless of whether it already supports widgets. You still have to upload the widgets plugin after this, though. http://www.erik-rasmussen.com/blog/index.php?p=140 Filed under WordPress by Tom Permalink • Print • Email • Comment [...]
[...] ダウンロード:Erik’s Blog » Widgetize Anything [...]
[...] kann, die eben nicht als Widgets geschrieben sind. Da habe ich zum Glück auch was gefunden: Widgetize Anything – das ist wirklich genial. Da kann man direkt auch PHP Code einfügen und eben auch den Code [...]
[...] 在侧栏显示随即文章 需要桑葚中文 WordPress 工具箱和 Widgetize Anything 两个插件,然后在模板的Sidebar Widgets 里增加一个Widgetize Anything1 ,内容为 [ [...]
Wow, thanks for this great plugin Erik, it works like a charm.
Installation was easy (WP 2.1.2) on my local test system. Hope it works even smooth when my page goes online.
greets
Mikrosenshi
Rats! Just upgraded to WP 2.2 and it messed up this great plugin.
(
I get this message now:
Warning: Missing argument 2 for widgetize_anything() in /xxxx/xx/xxxxxx/xx/xx/wp-content/plugins/widgetize-anything/widgetize-anything.php on line 15
What should I do to fix it?
Thank,
gestroud
gestroud: Thanks for letting me know. I’ve upgraded my blog and fixed the plugin. Just re-download it and it should work fine.
It’s version 1.1 now. Yay!
Excellent!! Thank you, Erik!
hello..can you help me please
i really dont know how to use echo strings
i just copy paste this thing
and error occured
can u help me how to make this under echo strings
sorry i really dont know about php
thanks!!
anthabax: I’m sorry, but this plugin really does require a very basic knowledge of PHP. Any code that you can get to work directly in a php file (inside <?php ?> tags!) will work in a Widgetize Anything widget.
Practice with a file, like your header.php, and then, once you get it working, paste that code into your widget. There are thousands of PHP tutorials out there. This page is not one of them.
Good luck!
Is it possible to make this MU compatible? Great plugin BTW!
Probably. I assume it would just be a matter of accessing the “options” values for the plugin a little differently. Unfortunately, I have little interest in MU myself. But if someone else wanted to modify the plugin for dual compatibility, I’d accept the fix.
I honestly suspect that the final destiny of this plugin is to be incorporated into the main Wordpress codebase. It’s such a simple and universally useful idea. Now that widgets have been made standard in version 2.2, I don’t think it will take long for them to allow PHP in widget code.
The current download of the ZIP file is not correct for wordpress-2.2; there is no longer a need to check for ‘wp_register_sidebar_widget’ (no need for the extra “null” argument).
I think I’m gonna stop upgrading WP. Under the latest version, 2.2.1 none of the widgetize anything panels appear. Or I shoud say that they appear, but they are empty and the titles don’t show up.
Widgetize anything is not working with 2.2.1 for me too.
I posted a support ticket to wordpress.org and their answer was to change plugin!!!
See for yourselves: Problems with 2.2.1 and Widgetize Anything
Widgetize anything is a very good plugin and we need it functional on WP 2.2.1
Please fix the problem
Thanks
Sorry, guys, I was out of town for a few days.
This has been fixed. Redownload version 1.2. They keep changing the way widgets are registered.
I don’t know if version 1.2 is compatible with previous versions of Wordpress.
I can confirm the latest version works with WordPress MU 1.2.3. Thanks Erik for this great plugin!
Erik,
Thank you for the diligence you pay in keeping this plugin updated. Much appreciated.
gestroud
Thank you Erik for keeping this plugin updated
It works like a charm with 2.2.1
Hi Erik,
I got following error when tried 2 use it.
I tried two widgets & got same error in both.
”
Parse error: syntax error, unexpected ‘
prashanth: It’s probably a problem in your PHP code. Do two things:
1) verify that the ‘hello world’ example in the post above works.
2) verify that the exact php code you have in the widget body works in a regular php file inside the php tags.
If #1 works and #2 doesn’t, then it’s a problem on your end, and you’ve got unmatching quotes in your PHP code. But if #2 works and #1 doesn’t, then it’s a problem with the plugin and you should let me know.
Cheers,
Erik
Hello Erik,
Thanks a lot for releasing such an excellent plugin like this. I have tried using your widget with the latest version of Wordpress (2.2.1). Everything works fine, except that I can have only one instance of “Widgetize Anything” widget. I would like to have more than one instance like the text widget. Can you please tell me what to do?
Regards
I found the option. It would have really good if it was displayed right below the widgets, like the text and rss widget options.
Thanks
Yes, that would be nice, but I don’t think it’s possible to modify that page. Or if it is, I don’t know how. Glad you found the solution, though.
Thanks for this great plugin. However, even though I’ve downloaded the new version several times, WP still reports v. 1.1 when I install it and it doesn’t work in 2.2.1. Any suggestions what to do?
Henrik: The version number thing was because I’m and idiot and forgot to change it. If you redownload it, it should say 1.2. Can you explain exactly how it “doesn’t work” in 2.2.1? Can you enable the plugin? Does it show up in the widget admin? Can you add them to the sidebar?
Wow! You really respond quickly…
BTW, WP still claims it’s v 1.1, but that doesn’t really matter. Anyway, I can install the plugin without any difficulties and the settings from v 1.1 remain in place, as does the number of WA widgets:
However, on the blog, none of the contents of the widgets show up (capture of part of the sidebar section):
In the widgets, I use the following calls to plugins:
#1: get_random_posts
#2: InSeries::SeriesList
#3: c2c_get_recent_posts
#5: c2s_get_recent_posts
Again, thanks for your awesome work (which I rely heavily on for my blogging, as you can see…)
No errors? Just no content?
All the sudden, it started working again, now that I tried a couple of hours later. Weird… But that’s exactly what happened – no errors, but no content and when looking at the source, the markers (the insertion comment) were there.
Anyway, thanks for looking into it and sorry for the inconvenience. Guess it’s a while before I understand how WP works…
Maybe you hadn’t hit “Save Changes” in the WP admin? I can see how it wouldn’t be immediately obvious to a first time WP users that you had to click that button.
Anyway, glad it’s working. I really fixed the version number now. I swear! I had only fixed the .tar.gz version at my last comment, but now it’s right in the .zip.
javascript:alert(xss);
I am code stupid….anyone got a quick cut and paste for ad rotator? Need more than the 9 they give you!
Thanks
Hola, ¿el plugin es compatible con las versiones actuales de wp?.
Gracias
Galileo, sí. Lo estoy usando yo ahora mismo con 2.2.1. Todavía no he probado con 2.3.
Great Plugin!
Is there a fix on the way for Wordpress 2.3?
Thanks.
It works fine in 2.3. I just upgraded and my sidebar is using it right now.
I get this with just text:
Parse error: syntax error, unexpected T_STRING in /home/xxxxx/public_html/wp-content/plugins/widgetize-anything/widgetize-anything.php(31) : eval()’d code on line 1
I think I get some other error with php in the box. Everthing worked fine until the 2.3 uprgrade.
Thanks.
Lynch: That error means that some part of the PHP that you’re putting into the widget doesn’t work. Try pasting it temporarily into an actual PHP file, like your header.php and see if it works properly. I suspect that you’re calling some WP function that no longer exists or has changed somehow. I hope this helps..
Yes. It was the PHP. Sorry for the bother. Thanks for the help.
excellent post. thansk for sharing.
There’s a problem with the Options – Widgetize Anything feature. When I’m in the admin section, and I click on Options -> Widgetize Anything, I get a 404 error. Is it a problem with 2.3?
I get the following parse error using WP 2.3 (taken from source code)
Parse error: parse error in /Library/WebServer/Documents/wordpress/wp-content/plugins/widgetize-anything/widgetize-anything.php(31) : eval()’d code on line 1
This only occurs after I try to render the widget in a browser, other than that, the plugin functions. I have the following php code in my widget, replacing the first ? with a *:
*/
Thanks for help in advance.
Love this idea, but bad with code! Anyone have a cut and paste for me of the ad rotator code?
Thnax
Tony
Hi,great plugin!
Anyway to label the widgets differently than besides “widgetize Anything 1″?
Giun, no, there isn’t really, I’m afraid. That annoys me too. It would have to be done on the screen where you choose how many to have.
Caroline, if you haven’t figured it out yet. I got the same problem when i used a php code when i have the php tag inside the widget as
so all you need to do is not put the php tags – that worked for me ..good luck!
Nice plugin. Now i can create several plugin in a sec!
very interesting.
i’m adding in RSS Reader
Excellent!
I’m using this html to php converter online:
http://www.andrewdavidson.com/convert-html-to-php/
Then I paste it into the widget.
Easy way to get snippets into php!
Thanks!
Thanks for the plugin, works great. I had a little trouble learning how to call the echo part for a php function, so for those newbies just call this in the widget: echo function_name();
Thanks for that Ryan. It depends, of course, on whether the function you’re calling is returning the HTML as a string or actually writing it to the page. Plugins may vary on that.
Okay, I have been using the Widgetize this plugin for awhile and it has worked fine. I recently upgraded to WP 2.3.2 and it is either related or chance, but I cannot change anything IN an existing widget, or add anything to a new widget. It won’t save the changes. Anyone else see this, or do I have a conflict with another plugin?
Kaz, it’s probably a conflict with another plugin. I don’t know exactly how or which, but that’s what I suspect.
Kaz here again, more information on my issue with the inability to edit anything in the widget. This also extends to the built in “text widget” within WP. It seems there is conflict with IE7 (one report of 6) that is killing the process for many people. I cannot create a new Text Widget or alter an existing one, the same as with the Widgetize Anything widget…..
So, not necessarilly your issue, but is affecting it.
Search the WP Forums for Text Widget (http://wordpress.org/support/topic/139464)
Curious if you are using Firefox or not?
Because that is the “Fix”…. and it does work. I can log off IE and onto FF and use your widget perfectly. So it does not seem to be a conflict between widgets.
Anyone else try with IE and not working? ’cause if it isn’t anyone else maybe it is a IE configuration setting. I do notice even in FF that it takes a long time to write back to WP, I even get a message about “a script is running that is taking up resouces – do you want to continue”. I say yes, and a little later the changes appear, but only in FireFox. IE doesn’t even get that far.
Just thought you may want to know.. and if there is anything you can do to assist even better.
Kaz
Thanks for all that info, Kaz. If it’s a problem with the regular Text Widget, then I don’t think there’s much that I can do. It must be a general javascript issue with Wordpress. Yes, I use Firefox. I never use IE and I can’t really understand why anyone would.
Nice! Here is another plugin, that provides similar functionalities. I added some helpful features. So, if you like visit http://www.janek-niefeldt.de/blog/mycustomwidget.
It is a very nice plugin. How can I delete the widget created?
Cecilia: Drag it back off the sidebar, just like all other widgets.
I thought I’d offer up a tidbit of information to a previous poster. Yes, you *can* change the box names from “Widgetize Anything 1″ to something else. I’ve done it for a few clients, actually (hacked from this site:http://br.bingorabbit.com/wordpress-hack) – it works very well.
Hi,
I tried use your plugin and it doen´t works fine. It doesn´t allow change my sidebar more. The problem is:
%BEG_OF_TITLE%teste%END_OF_TITLE%hello world
Fatal error: Call to undefined function: ns_show_top_commentators() in /home/content/b/l/o/blogconcurso/html/money/wp-content/plugins/widgetize-anything/widgetize-anything.php(31) : eval()’d code on line 4
What can I do to continue using and solve this problem?
Thank you
Rodrigo
Rodrigo, cualquier código php que vale en un archivo php normal vale para el contenido del widget. Práctica con código dentro de un bloque de <?php en footer.php.
useful,thx!!
This is my first time using WP and first time using widgets. Despite the detailed steps on Erik’s page, I can’t seem to install the Widgetize Anything. Can anyone give me even more idiot-proof steps for installation on my Mac? Thanks.
I don’t think this plugin will work with WP 2.7. I had to remove it from my sites because it caused white pages in the admin area. Too bad, this was on of WordPress’ must-have plugins.
gestroud, it still works fine for me in WP 2.7.
I like this plugin, but:
I have a problem with this plugin and WordPress 2.7. I’ve entered php code into the widgetize anything widget in my sidebar, and now when I reload the sidebar in the admin to change the code, I’m being shown a string of php code and no option to edit the contents of the sidebar.
Any ideas?
I haven’t seen any behavior like that, eBiz. I suspect that your php code probably has a quote, either single or double, that is conflicting with 2.7’s javascript for widget editing. I’m not sure what to tell you. Maybe you can find and fix the php code in the database directly with phpmyadmin or something?
Hi, Erik. Thanks for the reply.
I don’t know what happened, but today I reinstalled the plugin and it works! And now my magazine is well on the way to being perfect!
Thanks!
My apologies. I used widgetize anything for 4 different plugins on a few different sites – finally narrowed it down to one plugin that completely wrecked Widgetize Anything’s functionality with WordPress 2.7. After removing the suspect plugin, Widgetize Anything works fine. Your plugin remains as great as ever.
Success BlogNet is a WordPress MU. Is this plugin compatible with MU?
Everything I have been reading here is sounding quite positive and I look forward to your reply
Best Regards,