Forums

Custom side bar - adding code to child functions (3 posts)

  1. dragonsjaw
    Member
    Posted 1 year ago #

    I have a child theme of 2010.
    I have managed to add more menus by using this code in child functions :

    <?php 
    
    // Remove the default 'register_nav_menus' function
    function remove_register_nav_menus() {
        remove_action( 'twentyten_setup', 'register_nav_menus' );
    }
    
    // Call 'remove_register_nav_menus' (above) during WP initialization
    add_action('after_setup_theme','remove_register_nav_menus');
    
    // Register new 'register_nav_menus' function by running 'register_nav_menus' on the 'twentyten_setup' hook. */
    add_action( 'twentyten_setup', 'register_nav_menus' );
    
    // This child theme uses wp_nav_menu() in three locations.
    register_nav_menus( array(
    	'primary' => __( 'Primary Navigation', 'twentyten' ),
    	'secondary' => __( 'Sidebar Menu', 'twentyten' ),
    	'third' => __( 'Bruce Sidebar Menu', 'twentyten' ),
    ) );
    ?>

    This is all fine and good, works great.
    But now when ever I try to add any other code to the functions file, I get errors.
    I am trying to set up a custom sidebar using:

    <?php
    
    add_action( 'widgets_init', 'my_register_sidebars' );
    
    function my_register_sidebars() {
    
    	/* Register the 'bcindex' sidebar. */
    	register_sidebar(
    		array(
    			'id' => 'bcindex',
    			'name' => __( 'bcindex' ),
    			'description' => __( 'Sidebar for Bruce Cockburn main page.' ),
    			'before_widget' => '<div id="%1$s" class="widget %2$s">',
    			'after_widget' => '</div>',
    			'before_title' => '<h3 class="widget-title">',
    			'after_title' => '</h3>'
    		)
    	);
    
    	/* Repeat register_sidebar() code for additional sidebars. */
    }
    
    ?>

    This actually registers a side bar visible in widgets, but as soon as I attempt to do anything an error code comes up:

    This is one from attempting to save a css change:
    Warning: Cannot modify header information - headers already sent by (output started at /home/****/public_html/**********/wp-content/themes/twentytenchild/functions.php:24) in /home/****/public_html/*(******.com/wp-admin/theme-editor.php on line 89

    This is one from trying to save a page modification:
    Warning: Cannot modify header information - headers already sent by (output started at /home/****/public_html/********.com/wp-content/themes/twentytenchild/functions.php:24) in /home/****/public_html/******.com/wp-includes/pluggable.php on line 890

    Is there something in the first part of this functions file that is causing these errors?
    This isn't the first code I have tried to use to get custom sidebars, every time I try to add anything to functions -- these errors come up.
    If I go back to just the menu set up in functions all is good.

    But I want to add custom sidebars.

  2. dragonsjaw
    Member
    Posted 1 year ago #

    Ok I tried several others ways to get a second sidebar.. they show up but the errors persist.

    I removed the child functions file as I wasn't able to save work with in the dashboard with out the headers errors.. always different depending on what i was doing. And I noticed my photospace page wasn't working either.
    Even though I had removed the call to make more menus(functions), I still have the created menus in the dash. ??

    This all started yesterday when I tried the plugin
    http://wordpress.org/extend/plugins/custom-shortcode-sidebars/

    I still am wondering if there is something 'wrong' with the above menu code??

  3. dragonsjaw
    Member
    Posted 1 year ago #

    Moved away from this code.. have new code and one question. Will start a new thread.

Topic Closed

This topic has been closed to new replies.

About this Topic