ThemeShaper Forums » Thematic

[closed]

index top widget for category page?

(4 posts)
  • Started 1 year ago by bhomatude
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. bhomatude
    Member

    I'm currently using the index top widget area for the posts page, but I'd also like to use it for all my category pages. Perhaps I need to add another widget area specifically for this? If so, what would I hook into ? I'm successfully adding a widget below the header (see code below) but that's not really what I want to do.

    //add widget below header
    
    // This will create your widget area
    function my_widgets_init() {
        register_sidebar(array(
           	'name' => 'Header Aside',
           	'id' => 'header-aside',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "",
    		'before_title' => "<h3 class=\"widgettitle\">",
    		'after_title' => "</h3>\n",
        ));
    
    }
    add_action( 'init', 'my_widgets_init' );
    
    // adding the widget area to your child theme
    function my_header_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('header-aside') ) {
        echo '<div id="header-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
        dynamic_sidebar('header-aside');
        echo '' . "\n" . '</div><!-- #header-aside .aside -->'. "\n";
    }
    }
    add_action('thematic_belowheader', 'my_header_widgets', 8);
    
    //end add widget below header
    Posted 1 year ago #
  2. what's wrong with the header widget you've created? is it in the wrong place or do you only want it to display on category pages?

    you could either adjust your conditional logic for displaying the dynamic_sidebar like so:

    // adding the widget area to your child theme
    function my_header_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('header-aside') && is_category()) {
        echo '<div id="header-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
        dynamic_sidebar('header-aside');
        echo '' . "\n" . '</div><!-- #header-aside .aside -->'. "\n";
    }
    }
    add_action('thematic_belowheader', 'my_header_widgets', 8);

    or you could put it on a hook that only displays on category pages, such as thematic_above_categoryloop() (which is also in a slightly different position)

    // adding the widget area to your child theme
    function my_header_widgets() {
    if ( function_exists('dynamic_sidebar') && is_sidebar_active('header-aside') ) {
        echo '<div id="header-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
        dynamic_sidebar('header-aside');
        echo '' . "\n" . '</div><!-- #header-aside .aside -->'. "\n";
    }
    }
    add_action('thematic_above_categoryloop', 'my_header_widgets');
    Posted 1 year ago #
  3. bhomatude
    Member

    Thanks Helga -- yes the widget I added was not in the correct place. I actually just wanted that index top widget to also display on category pages. I ended up just changing all my category pages to pages that displayed categorized posts. That allowed me to continue using the index top widget.

    But I'm going to take a look at your suggestion here for the future.

    Thanks again for your help!

    Posted 1 year ago #
  4. ugh, i don't really advise switching everything to pages. it is inefficient from a query standpoint. the blog template is going to one day be deprecated too.

    Posted 1 year ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.