Support » How-To and Troubleshooting » [Resolved] Getting Sidebar to work

[Resolved] Getting Sidebar to work

  • I’ve spent the last couple hours reading various posts in forum and still can’t get it to work. I’m using a slight modification of Kubrick’s theme. When I try to register the sidebar in the theme’s function.php, with <?php if ( function_exists(‘register_sidebar’) ) register_sidebar(); ?> and go to save it, I get Warning: Cannot modify header information – headers already sent by (output started at /home/altadena/www/www/wordpress/wp-content/themes/abc/functions.php:3) in /home/altadena/www/www/wordpress/wp-admin/theme-editor.php on line 55

    The blog is at http://www.altadenabaptist.org/wordpress/ and I suspect that it has something to do with the path but don’t know what to do to fix it.

    Other problems too, but one thing at a time, and this seems to be the initial problem that the others build on.

    Update: I edited it in Dreamweaver and reuploaded it and it seems to work as I can now see Widgets. So now, on to the next problem.

    I activated the Flexo Archives widget so that I can get that long archives list cut down to years, but I see nothing different.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Did you already have a functions.php with your theme with pre-existing code in it? If so, add:

    if ( function_exists('register_sidebar') ) register_sidebar();

    on a line on its own, but after the opening <?php tag. The issue is probably one of nesting <?php ... ?> tags, which cannot be done in PHP.

    Per instructions I’d already seen, I eliminated everything in the functions.php file and have ONLY this in it:

    <?php if ( function_exists(‘register_sidebar’) ) register_sidebar(); ?>

    I double checked and there is nothing before the first <?php and nothing after the last ?> either. I put my cursor in both places and pressed backspace and delete as appropriate to make sure. Any other suggestions?

    (output started at /home/altadena/www/www/wordpress/wp-content/themes/abc/functions.php:3)

    The end of this error output points to a line #3 existing in the theme’s functions.php. If you placed the code in it as you specify:

    <?php if ( function_exists('register_sidebar') ) register_sidebar(); ?>

    all on one line, then there should only be one line (and at best, the error should occur at line #2). So it’s likely some sort of formatting issue in the functions.php taking place upon saving. What are you using to edit it?

    I’m using 2.3.1 and go to Presentations > Theme Editor, then click on functions.php (in my ABC theme). Just to be sure, I did a select all and deleted everything, then saved, then did a copy/paste from the code above in this thread, and saved again.

    BTW, I’m no longer getting errors anyplace, it’s just that I’m not getting the new sidebar. When I go to Presentations > Widgets, I see Sidebar 1 and in it I have Flexo Archives, and Categories 1 and Meta – but in the blog itself, I’m still seeing my original sidebar.

    Should I start a new thread since the errors are gone? Or just stick with this thread?

    Playing around after reading some other threads, I’m now working in the sidebar.php. Here’s the way it starts out when it shows the “old” sidebar.

    <div id=”sidebar”>
    <?php if ( function_exists(‘register_sidebar’) ) register_sidebar(); ?>
    <snip the rest since it’s the part that works>

    Based on another thread I saw, I added this line:
    <?php if ( !function_exists(‘dynamic_sidebar’)
    || !dynamic_sidebar() ) : ?>
    because it looks like in addition to registering, it also needs to call it??? In any case, when I put that in so that I have:

    <div id=”sidebar”>
    <?php if ( function_exists(‘register_sidebar’) ) register_sidebar(); ?>
    <?php if ( !function_exists(‘dynamic_sidebar’)
    || !dynamic_sidebar() ) : ?>
    <snip the rest since it’s the part that works>

    But when I look at the blog, where the sidebar is I get:
    <b>Parse error</b>: syntax error, unexpected $end in <b>/home/altadena/www/www/wordpress/wp-content/themes/abc/sidebar.php</b> on line <b>76</b>

    So I took it back out. Since the editor doesn’t show line numbers I don’t know what line 76 is, but in any case, it would be down in the area that currently works ok. – update. I opened it it Dreamweaver and line 76 seems to be the very end – the ending of the file is:

    <li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
    					<?php wp_meta(); ?>
    			<?php } ?>

    So, what next?

    I had to solve my problem by going back to the default theme

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Getting Sidebar to work’ is closed to new replies.