Created
August 27, 2012 13:09
-
-
Save tommcfarlin/3488292 to your computer and use it in GitHub Desktop.
A simple example of how to add a basic sidebar to a WordPress theme
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
/** | |
* Registers a new sidebar with the theme. | |
* | |
* Note: replace 'themename' with the name of your theme. | |
*/ | |
function themename_add_sidebar() { | |
/* | |
* Description of the parameter array is as follows: | |
* | |
* name: The text that appears in the widgetized area in the Dahsboard | |
* id: The ID of the sidebar. It's a good practice to use sidebar-0, sidebar-1, etc to maintain compatibility so that widgets maintain their position across themes. | |
* description: The text that appears on the inside of the widgetized area in the Dashboard | |
* before_widget: The markup written to the front end that starts the sidebar. | |
* after_widget: The markup written to the front end that ends the sidebar. | |
* before_title: The markup to display before the widget's title text. | |
* after_title: The markup to display after the widget's title text. | |
* | |
*/ | |
register_sidebar( | |
array( | |
'name' => 'Sidebar Title', | |
'id' => 'sidebar-0', | |
'description' => 'The primary sidebar', | |
'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h3 class="widget-title">', | |
'after_title' => '</h3>' | |
) | |
); | |
} | |
add_action( 'widgets_init', 'themename_add_sidebar' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment