Adding Sidebar Textbox to Widget Page
-
The site I am customizing has only one sidebar and that contains blog information. After a lot of searching I found out how to ‘register’ a new sidebar and have it appear on the widget page. Then, using a widget, text can be added without having to fool around with HTML.
The problem is that I need two extra sidebars (for a total of 3) and I only get one, the last one registered.
Here is the code:
register_sidebar(array( 'name' => 'Sidebar Email', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="sidebartitle2">', 'after_title' => '</h2>' )); register_sidebar(array( 'name' => 'Sidebar Standard', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="sidebartitle2">', 'after_title' => '</h2>' ));My test site is at http://www.mydesignbook.net/artist_site.
-
Don’t forget to include the ID in the array:
function mdb_register_sidebar() { register_sidebar(array( 'name' => 'Sidebar Email', 'id' => 'sidebar-email', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="sidebartitle2">', 'after_title' => '</h2>' )); register_sidebar(array( 'name' => 'Sidebar Standard', 'id' => 'sidebar-standard', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="sidebartitle2">', 'after_title' => '</h2>' )); }and to call the dynamic sidebars place like below-codes in your template:
<?php dynamic_sidebar('sidebar-email');?> <?php dynamic_sidebar('sidebar-standard');?>I hope it works.
Samuel Elh, thanks for the tip!
The article I got the code from says nothing about including the “id”. But when I included it in the functions file, three sidebars show up on the widget page ready to be filled with content.
Umm. I understand it worked, right ?
You’re welcome 🙂
The topic ‘Adding Sidebar Textbox to Widget Page’ is closed to new replies.