Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * This is what registers any new sidebar ( widgetized area ) and is generally put in your functions.php file. It is often hooked to one of two functions: 'widgets_init' or 'after_setup_theme'
- */
- function my_sidebars(){
- // We register a sidebar with a name of 'Primary Sidebar' and an id of 'sidebar-1'
- // If you want to add more just repeat the lines of code and make sure you change the 'id'
- register_sidebar( array(
- 'name' => 'Primary Sidebar', /* The name of the sidebar. */
- 'id' => 'sidebar-1', /* Must be a unique id; this is what gets called by dynamic_sidebar( ) */
- 'before_widget' => '<div>', /* The opening tag that comes before any widget */
- 'after_widget' => '</div>', /* The closing tag of the widget */
- 'before_title' => '<h2 class="rounded">', /* The opening tag for the title of the widget */
- 'after_title' => '</h2>',b /* The closing tag for the widget title */
- ) );
- }
- add_action ( 'widgets_init', 'my_sidebars' );
- // This next part you put in your sidebar.php file
- /* Sidebar template */
- if ( is_active_sidebar( 'sidebar-1' ) : // checks to see if there are any active widget in the registered sidebar
- dynamic_sidebar( 'sidebar-1' ); // If so the use the sidebar with the id of sidebar-1
- else: // If there are no widgets run this instead
- the_widget( 'WP_Widget_Search' ); // Search widget
- endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement