WordPress.org

Ready to get started?Download WordPress

Forums

How can I have more text widgets in my template? (20 posts)

  1. thesp2
    Member
    Posted 6 years ago #

    Currently the default number of text widgets is 9. How can I add more number of text widgets?

  2. themystical
    Member
    Posted 6 years ago #

    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.

  3. thesp2
    Member
    Posted 6 years ago #

    It works!!!!! Thanks ton!!! :)

  4. godrox
    Member
    Posted 6 years ago #

    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?

  5. crysacraig
    Member
    Posted 6 years ago #

    I am also using 2.2 and would like more text widgets.

  6. crysacraig
    Member
    Posted 6 years ago #

    just wanted to let everyone know that this procedure works with 2.2. I just tried it.

  7. Chrizzles
    Member
    Posted 6 years ago #

    crysacraig - how did you find a widgets.php file in WP 2.2? I looked everywhere!

  8. crysacraig
    Member
    Posted 6 years ago #

    I sent into the wp-includes file. In there you will find your widgets.php file.

  9. Chrizzles
    Member
    Posted 6 years ago #

    I found widgets.php but it doesn't have a widget_text_setup function on the WP 2.2 version. :(

  10. themystical
    Member
    Posted 6 years ago #

    look at line 530 in widgets.php.

  11. fourcountrygals
    Member
    Posted 6 years ago #

    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
    Shari

  12. windyridge
    Member
    Posted 6 years ago #

    I have WP 2.3 does it work for that version also?

  13. ad9f30
    Member
    Posted 6 years ago #

    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

  14. ad9f30
    Member
    Posted 6 years ago #

    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.)

  15. neville
    Member
    Posted 6 years ago #

    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/

  16. azsportshub
    Member
    Posted 6 years ago #

    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?

  17. grumpyguy
    Member
    Posted 6 years ago #

    Thanks,

    Works like a charm

  18. theapparatus
    Member
    Posted 6 years ago #

    We covered RSS widgets in the mu forums in case anyone is interested.

  19. RoarinRow
    Member
    Posted 6 years ago #

    Worked for me on 2.3.1, thank you!

  20. kjetilgf
    Member
    Posted 6 years ago #

    Just want to add in that it works perfectly on WP 2.3.3
    Had to alter wp-includes/widgets.php - lines 570, 589, 601 and 604 - and now have 29 text widgets.

    And to show each of them in just one (out of (for now) 25) categories, I use the plugin Widget Logic as we've discussed here.
    (Also see the other explanations/links in that tread - for instance this)

    This combo has been so useful for me using WP as a CMS that I'd like to share it.
    Kjetil

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags