WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] One sidebar per category (2 posts)

  1. bechster
    Member
    Posted 5 years ago #

    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.

  2. bechster
    Member
    Posted 5 years ago #

    I found the solution. See cross posting here:
    http://wordpress.org/support/topic/282735?replies=4

Topic Closed

This topic has been closed to new replies.

About this Topic