Widget Plugin – How to add the additional text-widgets for your sidebar?

The Text-widget is the most useful widget in Widget plugin. It allows you to place the HTML code or Javascript on your sidebar. In my blog, I have used a lot of text-widgets for showing links, feed count, adsense, license, stats and so on. As you were like me, you may probably need more text-widgets for your sidebar. Unfortunately, there are only 9 text-widgets available in your widget by default. How do we do to get the additional text-widgets more than 9?

The answer is simple. You need to make a few minor changes in the code of widget plugin. Don’t worry if you are not programmer. It is very simple and everybody can do it… I will show the steps how to change and what to change the source code of widget plugin. Actually, there are only 3 lines to change so you just follow all those steps carefully and get it done.. :) Don’t forget to backup your code.

Note: Widget.php is located under wp-includes if you are using Wordpess 2.3. (Why not in plugins folder? Because the widget plugin is natively supported by wordpress started from version 2.3. ) To edit this file, you have to download this file to your local machine and have to upload it back after editing. You can’t use the plugin editor to edit this file.

Steps to follow ~

  1. Download widget.php file to your local machine and open it with your favorite text editor
  2. Find “wp_widget_text_setup” function. Change “9″ to “the number of text widgets you want” in this line “if ( $number > 9 ) $number = 9;”

  3. Find the “wp_widget_text_register” function. Change “9″ to “the number of text widgets you want” in this line “if ( $number > 9 ) $number = 9;” and “for ($i = 1; $i <= 9; $i++)”

     

  4. Find “wp_widget_text_page” function. Change 10 to the number which is one higher than the number of text-widget you want in this line “<?php for ( $i = 1; $i < 10; ++$i )”. (For example, if you want 20 text widgets, set 21 in that line. )

     

Finally, you can upload this file to your host after editing.. (Thanks to “Syntax” for this post. I got those steps from his post in wp.org forum. ). That’s all about adding the extra text-widgets. Let me know if you have any problem with those steps that I mentioned in this post. Thanks.

Reference ~

Links ~