ThemeShaper Forums » Thematic

[closed]

Adding new widget areas in #container ?

(4 posts)
  • Started 8 years ago by lifeisrisky
  • Latest reply from lifeisrisky
  • This topic is resolved
  1. I would like to split my #container into 2 widget areas, only on the index page. I am using the 2c-r-fixed.css and my #primary, #secondary and all 3 #subsidiary widget areas are used. So basically I need to add new widget areas, not reuse / move default widget areas. Any assistance or pointing in the right direction is appreciated. I can't seem to figure out how to add the widgets to the #container without destroying all the other page setups. :) Thank you in advance for your responses.

    Posted 8 years ago #
  2. I am looking for the same solution. I have been able to successfully add a widget are to the header and I'm wondering if it's the same process for the #container div.

    Posted 8 years ago #
  3. its pretty much the same as registering a new widget to the header, but instead use 'abovecontent'. this placing widget above content.

    the following should get you on the right track

    paste in functions.php

    function my_widgets_init() {
        register_sidebar(array(
           	'name' => 'Container Aside',
           	'id' => 'container-aside',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "",
    		'before_title' => "<h3 class=\"widgettitle\">",
    		'after_title' => "</h3>\n",
        ));
        register_sidebar(array(
           	'name' => 'Container Aside Two',
           	'id' => 'container-aside-two',
           	'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' );
    
    function category_widgets() {
    	if (is_home() || is_front_page()) {
            if ( function_exists('dynamic_sidebar') && is_sidebar_active('container-aside') ) {
    			echo '<div id="container-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    			dynamic_sidebar('container-aside');
    			echo '' . "\n" . '</div><!-- #header-aside .aside -->'. "\n";
    		}
    		if ( function_exists('dynamic_sidebar') && is_sidebar_active('container-aside-two') ) {
    			echo '<div id="container-aside" class="aside">'. "\n" . '<ul class="xoxo">' . "\n";
    			dynamic_sidebar('container-aside-two');
    			echo '' . "\n" . '</div><!-- #header-aside .aside -->'. "\n";
    		}
    	}
    }
    add_action('thematic_abovecontent', 'category_widgets', 2);

    paste in style.css

    #container .aside {
        width:250px;
        float:left;
        margin:0 30px 0 0;
    	background-color:#ccc;
    }

    the css will prob need further styling to fit your needs.

    all this is under the presumtion that these new widget areas are above the content or replacing the content. the line 'if (is_home() || is_front_page()) {' ensures the new widget area only shows on home page (as requested)

    i tried it out. demo here http://www.dev.virtualpudding.com/

    hope this helps

    Posted 8 years ago #
  4. @Jonny Janiero, excellent thank you! Marking resolved.

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.