One sidebar per category
-
Hi,
I often find myself in need of custom widgets or boxes of some sort for displaying related information on a per post/page basis.
Specifically, I’m trying to create a sidebar per category for displaying widgets with related content for each category in my category archive.
I have tried the following in functions.php but it doesn’t seem to work. However, I can’t figure out why it doesn’t. Does anyone have any ideas?
<?php $categories = get_categories('orderby=name&order=asc'); foreach ($categories as $category) { register_sidebar(array( 'name' => $category->category_name, 'id' => $category->category_nicename, 'before_widget' => '<div id="%1$s" class="%2$s widget">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' )); } ?>
Any help is much appreciated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘One sidebar per category’ is closed to new replies.