• I’m trying to figure out how to upgrade my theme to use Widgets. My current theme’s sidebar was within the code:

    <div id="sidebar">
    		<ul>
    [individual sidebar information within <li></li>]
                    </ul>
    	</div>

    As instructed at this link I took this to mean my theme was one of an unordered list. Therefore I added the following code at the top of my sidebar while closing it at the bottom:

    <?php if ( !dynamic_sidebar() ) : ?>

    It then mentioned placing the following code in the functions.php file

    <?php
        register_sidebar();
    ?>

    This is where I came stuck. I wasn’t sure where exactly to place it so I put it at the very top. This allowed me to set up widgets, but when it came to adding a post, installing a widget or updating a page I was getting an error message in place of what should have been my admin pages. Is there something wrong with where I am placing the code in the functions file, if so, where should I place it, and if not have I gone about coding my sidebar file incorrectly?

    Thanks for anyone who can provide some help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter prb81

    (@prb81)

    I should point out that I went with the assumption my sidebar wasn’t a list and put the following code at the top of my functions page:

    <?php
        register_sidebar(array(
            'before_widget' => '',
            'after_widget' => '',
            'before_title' => '<h2>',
            'after_title' => '</h2>',
        ));
    ?>

    It again shows the widgets, but when I go to add a new post or something to my site I get the following message:

    Warning: Cannot modify header information – headers already sent by (output started at /home/content/48/9255448/html/ALWAYSNEXTYEAR/wp-content/themes/any_white_v1.0/functions.php:10) in /home/content/48/9255448/html/ALWAYSNEXTYEAR/wp-includes/pluggable.php on line 881

    Assuming your functions.php file already had an opening <?php tag, just add:

    register_sidebar(array(
    	'before_widget' => '',
    	'after_widget' => '',
    	'before_title' => '<h2>',
    	'after_title' => '</h2>',
    ));

    after that opening tag.

    Thread Starter prb81

    (@prb81)

    Perfect. This has worked. I thank you.

    One question on the side. Using the widgets for my sidebar has made the gap between the end of one widget and the title for the next quite crammed. Where would I adjust code or whatever in order to spread them out a little?

    Thanks.

    You probably need to start editing your theme’s stylesheet. Try using Firefox with the Firebug add-on for this kind of CSS work.
    http://getfirebug.com/

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Problem updating for Widgets’ is closed to new replies.