WordPress.org

Support

Support » How-To and Troubleshooting » Adding footer sidebar

Adding footer sidebar

  • Hi,

    I’m trying to add a footer sidebar to my site, and struggling to figure out how. I’m using a child theme of Superhero, and it doesn’t let you add widgets in the footer as a default setting.

    I’ve tried inserting some php code into functions.php (as instructed by more than one site) but each time I do it it crashes the site completely, and I need to return to the default functions.php to reload it.

    Can anyone help?

    Thanks in advance…

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    @bcworkz

    This article gives nice overview of the process.

    A simple syntax error in functions.php can crash your entire site. There may not be anything wrong with the code except a missing semi-colon or something. To get a clue to the cause of the crash, define WP_DEBUG as true in wp-config.php.

    Thanks a lot for your response.

    I actually checked that site out and followed the instructions but it still caused my site to crash. I’ll try it again and look closely for syntax errors… Will be back on here if the same happens again!

    Ok, tried it again and when I load the site it comes up with the following:

    Fatal error: Cannot redeclare superhero_set_content_width() (previously declared in /home/paulc841/public_html/documentalfilms.co.uk/wp-content/themes/superhero-child/functions.php:21) in /home/paulc841/public_html/documentalfilms.co.uk/wp-content/themes/superhero/functions.php on line 25

    Here is the relevant code in functions.php (italics indicate what I have added):

    function superhero_widgets_init() {
    	register_sidebar( array(
    		'name'          => __( 'Sidebar', 'superhero' ),
    		'id'            => 'sidebar-1',
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h1 class="widget-title">',
    		'after_title'   => '</h1>',
    	) );
    }
    add_action( 'widgets_init', 'superhero_widgets_init' );
    function my_register_sidebars() {
    
    	/* Register the 'primary' sidebar. */
    	register_sidebar(
    		array(
    			'id' => 'primary',
    			'name' => __( 'Primary' ),
    			'description' => __( 'A short description of the sidebar.' ),
    			'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. */

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    }

    …sorry there is a closing brace there as well, forgot to copy it in 🙂

    Michael

    @alchymyth

    Forum Moderator

    do not copy the contents of functions.php from the parent theme into the child theme; only add new or pluggable functions or filter etc;

    http://codex.wordpress.org/Child_Themes#Using_functions.php

    i.e. try to start a new empty functions.php in your child theme, starting with <?php right at the start in the first line, and just with your sidebar codes

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding footer sidebar’ is closed to new replies.
Skip to toolbar