Lego2012
12/14/2016 - 1:21 PM

Condensed code to register 4 widget areas (Simplifying the code for displaying multiple widget areas in Genesis)

Condensed code to register 4 widget areas (Simplifying the code for displaying multiple widget areas in Genesis)

// Register front-page widget areas
for ( $i = 1; $i <= 4; $i++ ) {
   genesis_register_widget_area(
      array(
         'id' => "front-page-{$i}",
         'name' => __( "Front Page {$i}", 'my-theme-text-domain' ),
         'description' => __( "This is the front page {$i} section.", 'my-theme-text-domain' ),
      )
   );
}

<!-- goes in child theme's functions.php -->

<!-- The above is the same as -->

genesis_register_widget_area(
   array(
      'id' => "front-page-1",
      'name' => __( "Front Page 1", 'my-theme-text-domain' ),
      'description' => __( "This is the front page 1 section.", 'my-theme-text-domain' ),
   )
);

genesis_register_widget_area(
   array(
      'id' => "front-page-2",
      'name' => __( "Front Page 2", 'my-theme-text-domain' ),
      'description' => __( "This is the front page 2 section.", 'my-theme-text-domain' ),
   )
);

genesis_register_widget_area(
   array(
      'id' => "front-page-3",
      'name' => __( "Front Page 3", 'my-theme-text-domain' ),
      'description' => __( "This is the front page 3 section.", 'my-theme-text-domain' ),
   )
);

genesis_register_widget_area(
   array(
      'id' => "front-page-4",
      'name' => __( "Front Page 4", 'my-theme-text-domain' ),
      'description' => __( "This is the front page 4 section.", 'my-theme-text-domain' ),
   )
);