WordPress.org

Ready to get started?Download WordPress

Forums

How can I create a new sidebar with tpl system? (1 post)

  1. rwilki
    Member
    Posted 1 year ago #

    I'm very familiar with wordpress, themes, and custom sidebars. I'm not as familiar with tpl templates though and I cannot figure out how to add a new sidebar with this system.

    Normally, I would just add some code to my functions file, create a new sidebar file and then adjust the page template file to display the new sidebar. With tpl, I don't have the same options. If someone can help with the functions file, it might point me in the right direction.

    I'm trying to add a new sidebar in this code, but have no idea where to inject it.

    'default-sidebar' => __('Default sidebar', 'theme'),
        'default-bottombar' => __('Default bottom widget area', 'theme')
      );
      foreach (array('sidebar' => __('sidebar', 'theme'), 'bottombar' => __('bottom widget area', 'theme')) as $type => $label)
      {
        $pages = get_pages(array
        (
          'hierarchical' => FALSE,
          'meta_key' => '_wp_page_template',
          'meta_value' => "tpl-individual-{$type}.php"
        ));
        foreach ($pages as $page)
          $sidebars["post-{$page->ID}-{$type}"] = $page->post_title.' '.$label;
      }
      foreach ($sidebars as $id => $name)
        register_sidebar(array
        (
          'name' => $name,
          'id' => $id,
          'before_widget' => '<li id="%1$s" class="%2$s">',
          'after_widget' => '</li>',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
        ));

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags