[wp-trac]
Re: [WordPress Trac] #8734: Call Sidebars by Static Name,
Not Dynamic Number
WordPress Trac
wp-trac at lists.automattic.com
Sat Dec 27 22:51:18 GMT 2008
#8734: Call Sidebars by Static Name, Not Dynamic Number
-------------------------+--------------------------------------------------
Reporter: dcole07 | Owner:
Type: enhancement | Status: new
Priority: high | Milestone: 2.8
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+--------------------------------------------------
Comment (by DD32):
So.. Sounds like you should pass in the Static name and static ID when
creating the sidebar, So as to select which one you want to show, as well
as being able to refer to it in CSS, as well as solving the widget
arranger problems..
ie:
{{{
add_action('init', 'theme_sidebars');
function theme_sidebars() {
register_sidebar(array(
'name' => 'Left Posts sidebar',
'id' => 'left-posts-sidebar',
'before_widget' => '<div
class="widget">',
'after_widget' => '</div>'
));
register_sidebar(array(
'name' => 'Left Home sidebar',
'id' => 'left-home-sidebar',
'before_widget' => '<div
class="widget">',
'after_widget' => '</div>'
));
}
}}}
the code to call those looks like:
{{{
$is_blog = ( is_home() || is_single() || is_archive() ||
is_attachment() );
$sidebar = $is_blog ? 'left-posts-sidebar' : 'left-home-sidebar';
?>
<div class="sidebar <?php echo $sidebar ?>" id="<?php echo
$sidebar ?>">
<?php
dynamic_sidebar($sidebar);
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/8734#comment:1>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list