Rather than include this boilerplate code in my starter theme, I’m saving it here so that I can copy and paste it when I need to.
The array_map
function will iterate over $widget_areas
, meaning one iteration is one widget area, and passes the widget area configuration to the Genesis function genesis_register_widget_area
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Register widget areas. | |
* | |
* @uses genesis_register_widget_area() | |
* | |
* @since 1.0.0 | |
*/ | |
add_action( 'widgets_init', function () { | |
$widget_areas = [ | |
[ | |
'id' => 'example-widget-area', | |
'name' => __( 'Example Widget Area', 'generico' ), | |
'description' => __( 'This is an example widget area, it\'s not used for anything in particular.', 'generico' ), | |
], | |
[ | |
'id' => 'another-widget-area', | |
'name' => __( 'Another Widget Area', 'generico' ), | |
'description' => __( 'This is another example widget area, it\'s not used for anything in particular.', 'generico' ), | |
] | |
]; | |
array_map( 'genesis_register_widget_area', $widget_areas ); | |
}, 5 ); |
Leave a Reply