register_sidebar id not working
-
I’ve written a function to register 3 sidebars.
If I don’t specify an ID => value, then the call to dynamic_sidebar(‘name’) works just fine.But if I specify an ID => value (all lowercase, no spaces, unique) then both dynamic_sidebar(‘name’) and dynamic_sidebar(‘id’) fail.
But I’d really like to assign an ID to a widget.
Here’s my code:
in theme functions.phpif ( function_exists('register_sidebar') ) { function osc_widgets_init() { register_sidebar(array( 'name'=>'Sidebar for Blog List', 'id' => 'sidebar_for_blog_list', 'before_widget' => '<section class="widget">', 'after_widget' => '</section>', 'before_title' => '<h1>', 'after_title' => '</h1>', )); register_sidebar(array( 'name'=>'Sidebar for Pages', 'id' => 'sidebar_for_pages', 'before_widget' => '<section class="widget">', 'after_widget' => '</section>', 'before_title' => '<h1>', 'after_title' => '</h1>', )); register_sidebar(array( 'name'=>'Sidebar for Footer', 'id' => 'twitter_hash_tag-3', 'before_widget' => '<li class="widget">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); } add_action( 'widgets_init', 'osc_widgets_init' ); }
As an example, in footer.php
<?php if ( dynamic_sidebar('Sidebar for Footer') ) : else : ?> <?php endif; ?>
That doesn’t work. Neither does this:
<?php if ( dynamic_sidebar('twitter_hash_tag-3') ) : else : ?> <?php endif; ?>
So, the only thing that works so far is letting WP assign default IDs and calling dynamic_sidebar(‘name’).
Suggestions on what I’m doing wrong?
[Moderator – Moved the themes and templates]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘register_sidebar id not working’ is closed to new replies.