Skip to main content
Small format changes
Source Link
MikeSchinkel
  • 37.5k
  • 14
  • 116
  • 132

I think what you might need is simply to run register_sidebar() in an widgets_init'widgets_init' hook. The TwentyTen theme has examples for register_sidebar() in its functions.php file, but here's what it might look like (I didn't test this code so you might have to play with it a bit to get it working)::

add_action( 'widgets_init', 'yoursite_init''twentyten_widgets_init' );
function yoursite_inittwentyten_widgets_init() {
  register_sidebar( array(
    'name' => __( 'News Sidebar', 'yoursite' ),
    'id' => 'sidebar-news',
    'description' => __( 'The News Sidebar Area', 'yoursite' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
  ));
  
  /*
   * THE REST OF THE SIDEBAR REGISTRATION CODE FROM twentyten_widgets_init() GOES HERE
   */
}

Also, in your template_news.php page template use the following code to call your sidebar which will load the sidebar-news.php file you created above:

<?php get_sidebar( 'news' ); ?> 

You shouldn't need any of the other things you tried, and definitely not any include statements.

I think what you might need is simply to run register_sidebar() in an widgets_init hook. The TwentyTen theme has examples for register_sidebar() in its functions.php file, but here's what it might look like (I didn't test this code so you might have to play with it a bit to get it working):

add_action( 'widgets_init', 'yoursite_init' );
function yoursite_init() {
  register_sidebar( array(
    'name' => __( 'News Sidebar', 'yoursite' ),
    'id' => 'sidebar-news',
    'description' => __( 'The News Sidebar Area', 'yoursite' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
  ));
}

I think what you might need is simply to run register_sidebar() in an 'widgets_init' hook. The TwentyTen theme has examples for register_sidebar() in its functions.php file, but here's what it might look like:

add_action( 'widgets_init', 'twentyten_widgets_init' );
function twentyten_widgets_init() {
  register_sidebar( array(
    'name' => __( 'News Sidebar', 'yoursite' ),
    'id' => 'sidebar-news',
    'description' => __( 'The News Sidebar Area', 'yoursite' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
  ));
  
  /*
   * THE REST OF THE SIDEBAR REGISTRATION CODE FROM twentyten_widgets_init() GOES HERE
   */
}

Also, in your template_news.php page template use the following code to call your sidebar which will load the sidebar-news.php file you created above:

<?php get_sidebar( 'news' ); ?> 

You shouldn't need any of the other things you tried, and definitely not any include statements.

Source Link
MikeSchinkel
  • 37.5k
  • 14
  • 116
  • 132

I think what you might need is simply to run register_sidebar() in an widgets_init hook. The TwentyTen theme has examples for register_sidebar() in its functions.php file, but here's what it might look like (I didn't test this code so you might have to play with it a bit to get it working):

add_action( 'widgets_init', 'yoursite_init' );
function yoursite_init() {
  register_sidebar( array(
    'name' => __( 'News Sidebar', 'yoursite' ),
    'id' => 'sidebar-news',
    'description' => __( 'The News Sidebar Area', 'yoursite' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
  ));
}