Adding footer sidebar (7 posts)

  1. Paul
    Posted 2 years ago #


    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...

  2. bcworkz
    Posted 2 years ago #

    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.

  3. Paul
    Posted 2 years ago #

    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!

  4. Paul
    Posted 2 years ago #

    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

  5. Paul
    Posted 2 years ago #

    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. */
    			'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.]

  6. Paul
    Posted 2 years ago #


    ...sorry there is a closing brace there as well, forgot to copy it in :)

  7. Michael
    Forum Moderator
    Posted 2 years ago #

    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;


    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

Topic Closed

This topic has been closed to new replies.

About this Topic