Support » Plugin: Code Snippets » Adding a widget area keeps breaking my site

  • Resolved earrame


    Hello, I have added the following code to add a widget area into a genesis child theme. I tried the code at the bottom of the functions.php file and it worked like a charm. When I put in Code Snippet, the site breaks (gray screen) and I have to go into safe mode to fix it. Here is the code:

      genesis_register_sidebar( array(
    'id' => 'after-header-widget',
    'name' => __( 'After Header Widget', 'genesis' ),
    'description' => __( 'After Header Widget Area', 'daily-dish-pro' ),
    ) );
    add_action( 'genesis_after_header', 'add_genesis_widget_area' );
    function add_genesis_widget_area() {
                    genesis_widget_area( 'after-header-widget', array(
    		'before' => '<div class="after-header-widget widget-area">',
    		'after'  => '</div>',
        ) );

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • I have narrowed it down to the register section and fixed one issue with it, but it is still crashing the site. If I put this in a snippet and save it, the site goes gray.

    genesis_register_sidebar( array(
    ‘id’ => ‘after-header’,
    ‘name’ => __( ‘After – Header’, ‘daily-dish-pro’ ),
    ‘description’ => __( ‘After Header Widget Area’, ‘daily-dish-pro’ ),
    ) );

    Plugin Author Shea Bunge


    Hi @earrame,

    I believe this is happening because snippets are being loaded before Genesis has had a chance to run. Instead, you should wrap function calls like this in some sort of action hook:

    add_action( 'init', function () {
    	genesis_register_sidebar( array(
    		'id' => 'after-header',
    		'name' => __( 'After – Header', 'daily-dish-pro' ),
    		'description' => __( 'After Header Widget Area', 'daily-dish-pro' ),
    	) );
    } );

    Thank you very much! That worked perfectly!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding a widget area keeps breaking my site’ is closed to new replies.