How can I have more text widgets in my template?
-
Currently the default number of text widgets is 9. How can I add more number of text widgets?
-
Being said I’m not expert, I think this should work. You are using wp 2.1.3 right? So I assume you installed the widgets plugin, right?
Well I changed few things in the widgets.php located in ../wp-content/plugins/widgets/
Buckup everything, you never know, if something fails don’t blame me ok? π
I did a search in the code for widget_text and found this:
function widget_text_setup() { $options = $newoptions = get_option('widget_text'); if ( isset($_POST['text-number-submit']) ) { $number = (int) $_POST['text-number']; if ( $number > 9 ) $number = 9; if ( $number < 1 ) $number = 1; $newoptions['number'] = $number;
You can see the number 9, so I changed it to lets say 15
After that just few lines below that code there is this:
function widget_text_page() { $options = $newoptions = get_option('widget_text'); ?> <div class="wrap"> <form method="POST"> <h2><?php _e('Text Widgets', 'widgets'); ?></h2> <p style="line-height: 30px;"><?php _e('How many text widgets would you like?', 'widgets'); ?> <select id="text-number" name="text-number" value="<?php echo $options['number']; ?>"> <?php for ( $i = 1; $i < 10; ++$i )
On the line (should be 885) with <?php for ( $i = 1; $i < 10; ++$i ) I changed number 10 to 16, remember, add one to the number of text widgets you set, so in my case I want 15 and this number is set to 16.
After that, one more step, look for:
function widget_text_register() { $options = get_option('widget_text'); $number = $options['number']; if ( $number < 1 ) $number = 1; if ( $number > 9 ) $number = 9; for ($i = 1; $i <= 9; $i++)
And as before change all 9s to your needs, as for sake of this example I set it to 15.
Save the files and test that everything works fine, if everything fails revert to the original copy.
I think this should do it, if any more knowladgable guy think this is wrong and I’m missing something please correct me.
Again, before you do anything I advise you to back up a copy of widgets.php file, well actually backup everything! Just in case.
Have a nice one, bye.
It works!!!!! Thanks ton!!! π
I need to add more text widgets, as well, but I’m using WP 2.2 and it looks like /wp-includes/widgets.php is different. Anyone know how I can do this in 2.2?
I am also using 2.2 and would like more text widgets.
just wanted to let everyone know that this procedure works with 2.2. I just tried it.
crysacraig – how did you find a widgets.php file in WP 2.2? I looked everywhere!
I sent into the wp-includes file. In there you will find your widgets.php file.
I found widgets.php but it doesn’t have a widget_text_setup function on the WP 2.2 version. π
look at line 530 in widgets.php.
Boy, am I ever glad I was persistent with my search. This fix was exactly what I needed… and it worked on the very first try!
Thanks
ShariI have WP 2.3 does it work for that version also?
I cannot find wp-includes or widgets.php but would also have a need for more than 9 text widgets. I’m using 2.3
For anyone wondering, as I was, where to go to find widgets.php here’s what I did. I found wp-includes as a file in my blog site using CPanel. When I opened the wp-includes folder I could see widgets.php. I edited it just as “themystical” said and, voila, I had 11 additional text widgets (for a total of 20.)
I upgraded to 2.3.1 today. One of the first things I did was implement this hack. It works perfectly on 2.3.1.
As noted above, the file to edit is widgets.php in /wp-includes (not the one in /wp-admin).
I followed agentsully’s great guide:
http://lifelearningtoday.com/2007/04/18/make-more-than-9-text-sidebar-widgets-in-wordpress-plugins/I just implemented this hack and now i have the option of going up to 20 widgets, but it doesn’t seem to be creating them. I followed this step by step. Any ideas?
- The topic ‘How can I have more text widgets in my template?’ is closed to new replies.