• Resolved edwardgyngell

    (@edwardgyngell)


    Hello, I am new to wordpress and have just built my first theme.
    I am having problems with the sidebar and it’s widgets. It is making this error display in my dashboard;

    The error says
    warning: Cannot modify header information – headers already sent by (output started at /home/ringuet/public_html/journal/wp-content/themes/ringuet/functions.php:14) in /home/ringuet/public_html/journal/wp-includes/functions.php on line 862

    This is what the functions.php looks like

    <?php
    	if (function_exists('register_sidebar')) {
    		register_sidebar(array(
    			'name' => 'Sidebar Widgets',
    			'id' => 'sidebar-widgets',
    			'description' => 'Widgets for the sidebar.',
    			'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    			'after_widget' => '</aside>',
    			'before_title' => '<h3>',
    			'after_title' => '</h3>',
    		));
    	}
    ?><code></code>

    and this is what the sidebar.php looks like

    <div class=”widget-area center”>
    <?php if ( ! dynamic_sidebar( ‘Sidebar Widgets’ ) ) : ?>

    <?php endif; ?>

    </div> <!– close widget –>

    This is the blog I am working on: http://ringuet.com.au/journal/

    Can anyone tell what I have coded wrong?

    Thanks in advance.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi edwardgyngell,

    The headers already sent error is usually because of extra white space after closing php tags.

    Check your functions.php file and make sure there are no blank spaces or lines after your last ?> tag.

    Also when calling your dynamic sidebar use the registered sidebars id.

    dynamic_sidebar( 'sidebar-widgets' );

    Thread Starter edwardgyngell

    (@edwardgyngell)

    Thanks for the reply Chris.
    I made the changes suggested but no go. It is still displaying an error in my dashboard.

    Any other suggestions?

    Can you post your whole functions.php file to http://pastebin.com and provide a link.

    Thread Starter edwardgyngell

    (@edwardgyngell)

    This is the whole function

    http://pastebin.com/twG8ju36

    Is that the entire contents of functions.php?

    Thread Starter edwardgyngell

    (@edwardgyngell)

    Yeah thats it.

    When you register a sidebar it needs to be wrapped inside a function then that function needs to be added to the widgets_init hook. Please try this.

    function ringuet_reg_sidebar() {
    	register_sidebar( array (
    			'name'          => 'Sidebar Widgets',
    			'id'            => 'sidebar-widgets',
    			'description'   => 'Widgets for the sidebar.',
    			'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</aside>',
    			'before_title'  => '<h3>',
    			'after_title'   => '</h3>',
    		)
    	);
    }
    
    add_action( 'widgets_init', 'ringuet_reg_sidebar' );

    Do not put a closing php tag. Just replace your functions.php with the code above.

    Thread Starter edwardgyngell

    (@edwardgyngell)

    That worked a treat. Thanks heaps.

    I have one more issue that I can’t figure out and I thought it may have been that issue but it wasn’t. There seems to be a massive margin top on the top of my blog page. I thought the error lines might have been pushing it down but that doesn’t seem to be the case. Would you have any idea how to fix this?

    Please open a new support topic for your margin issues. Provide as much detail as possible. I’m marking this topic as resolved.

    Thread Starter edwardgyngell

    (@edwardgyngell)

    No worries. Thanks again.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Dashboard error from sidebar caused by functions.php’ is closed to new replies.