Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter seanfilidis

    (@seanfilidis)

    Fixing the missing bracket in my stylesheet solved all the problems. Is there a particular tool you use to check for syntax errors like that?

    Still stumped as to how the problem suddenly manifested.

    Thanks

    Thread Starter seanfilidis

    (@seanfilidis)

    This is my custom sidebar in my child functions.php

    <?php
    
    function twentythirteenchild_widgets_init() {
    
    	register_sidebar( array(
    		'name'          => __( 'Third Widget Area', 'twentythirteen' ),
    		'id'            => 'sidebar-3',
    		'description'   => __( 'Is only for the front page.', 'twentythirteen' ),
    		'before_widget' => '<aside id="%1$s" class="widget widget-fp1">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h3 class="widget-title">',
    		'after_title'   => '</h3>',
    	) );
    }
    
    add_action( 'widgets_init', 'twentythirteenchild_widgets_init' );
    
    ?>

    Wow… I could just us the after_widget attribute. Oh, no that would add it to every widget, I only want to edit that particular one.

    Thread Starter seanfilidis

    (@seanfilidis)

    I want it in the menu itself (within the generated <aside> tags).

    But all that I see in the template is <?php dynamic_sidebar( ‘sidebar-3’ ); ?>. So there is nowhere to insert code.

    Thread Starter seanfilidis

    (@seanfilidis)

    Presto! Thanks.
    My code now looks like this

    <?php
    
    function twentythirteenchild_widgets_init() {
    
    	register_sidebar( array(
    		'name'          => __( 'Third Widget Area', 'twentythirteen' ),
    		'id'            => 'sidebar-3',
    		'description'   => __( 'Is only for the front page.', 'twentythirteen' ),
    		'before_widget' => '<aside id="%1$s" class="widget widget-fp1">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h3 class="widget-title">',
    		'after_title'   => '</h3>',
    	) );
    }
    
    add_action( 'widgets_init', 'twentythirteenchild_widgets_init' );
    
    ?>

    Thread Starter seanfilidis

    (@seanfilidis)

    From what I read, putting that conditional in the beginning should prevent the problem, but it doesn’t seem to be working.

    Thread Starter seanfilidis

    (@seanfilidis)

    I did. I now realize you can’t do that. The child theme’s functions.php should only contain new functions.

    But I have a problem then. I am using the functions.php to create an additional sidebar. I just deleted everything in the functions.php except for this function. But I still get a similar error.

    Here is the code in my child theme’s functions.php:

    <?php
    
    if ( ! function_exists( 'twentythirteen_widgets_init' ) ) {
    
    function twentythirteen_widgets_init() {
    	register_sidebar( array(
    		'name'          => __( 'Main Widget Area', 'twentythirteen' ),
    		'id'            => 'sidebar-1',
    		'description'   => __( 'Appears in the footer section of the site.', 'twentythirteen' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h3 class="widget-title">',
    		'after_title'   => '</h3>',
    	) );
    
    	register_sidebar( array(
    		'name'          => __( 'Secondary Widget Area', 'twentythirteen' ),
    		'id'            => 'sidebar-2',
    		'description'   => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h3 class="widget-title">',
    		'after_title'   => '</h3>',
    	) );
    
    	register_sidebar( array(
    		'name'          => __( 'Third Widget Area', 'twentythirteen' ),
    		'id'            => 'sidebar-3',
    		'description'   => __( 'Is only for the front page.', 'twentythirteen' ),
    		'before_widget' => '<aside id="%1$s" class="widget widget-fp1">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h3 class="widget-title">',
    		'after_title'   => '</h3>',
    	) );
    }
    }
    
    ?>

    As you can see I just added a third sidebar. However I now get this fatal error message:

    Fatal error: Cannot redeclare twentythirteen_widgets_init() (previously declared in /home/content/20/11764620/html/wordpress/wp-content/themes/twentythirteen-child/functions.php:7) in /home/content/20/11764620/html/wordpress/wp-content/themes/twentythirteen/functions.php on line 245

Viewing 6 replies - 1 through 6 (of 6 total)