Created
April 7, 2013 15:55
-
-
Save saramarie/5331041 to your computer and use it in GitHub Desktop.
WordPress: Easy way to create new widget areas
This file contains hidden or 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
| /*================================================ | |
| = Widget Area Registration = | |
| ================================================*/ | |
| $widget_list = array ( | |
| // Create a new sidebar by adding its name here | |
| 'Primary Sidebar', | |
| 'Left Footer', | |
| 'Left Center Footer', | |
| 'Right Center Footer', | |
| 'Right Footer' | |
| ); | |
| if (function_exists('register_sidebar')) { | |
| $count = 0; | |
| foreach ($widget_list as $widget) { | |
| $widget_id = str_replace(' ', '_', strtolower($widget)); | |
| $widget_set[$count] = array ( | |
| 'name' => $widget, | |
| 'id' => $widget_id, | |
| 'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
| 'after_widget' => '</div>', | |
| 'before_title' => '<h3>', | |
| 'after_title' => '</h3>' | |
| ); | |
| $count++; | |
| } | |
| for ($i = 0; $i < $count; $i++) { | |
| register_sidebar($widget_set[$i]); | |
| } | |
| } | |
| /*----- End of Widget Area Registration ------*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment