ThemeShaper Forums » Thematic

[closed]

Adjusting widgetized areas

(6 posts)
  • Started 4 years ago by mariusooms
  • Latest reply from marcrock
  • This topic is not resolved
  1. Is there a way to disable certain widgetized areas for my child theme? Currently I don't need all 13 of them as my child theme is fairly simple.

    I want to avoid changing theme code so I was hoping to add a remove_action or something like that in my functions.php. I'm not totally sure what I should do.

    Thanks in advance,

    Marius

    Posted 4 years ago #
  2. You might use a CSS declaration of "display: none;" applied to whichever widget area you want to avoid displaying. This will leave the widget area accessible from the back end of the blog, but it won't show up on the front end, even if someone puts a widget into it. Plus, it is easy to comment out if a user wants to add a widget area back (just make sure you give it some "default" styling to match your theme just above the "display: none;" line).

    Posted 4 years ago #
  3. Here's a hint: http://codex.wordpress.org/Function_Reference/unregister_sidebar

    Should get you going in the right direction.

    Posted 4 years ago #
  4. I was searching the forums for something else, but noticed this had never been answered entirely. The following code removes some widget areas, it renames some, and then it adds an entirely new widget area so that I have four footer areas. You can obviously re-factor this code to how you need it:

    // Removing Widget Areas
    
    function remove_widget_areas($content) {
    	unset($content['Index Insert']);
    	unset($content['Single Insert']);
    	unset($content['Index Top']);
    	unset($content['Index Bottom']);
    	unset($content['Single Top']);
    	unset($content['Single Bottom']);
    	unset($content['Page Top']);
    	unset($content['Page Bottom']);
    	return $content;
    }
    add_filter('thematic_widgetized_areas', 'remove_widget_areas');
    
    // Renaming Widget Areas
    
    function rename_widgetized_areas($content) {
    	$content['Primary Aside']['args']['name'] = 'Image Rotator';
    	$content['Secondary Aside']['args']['name'] = 'Right Sidebar';
    	$content['1st Subsidiary Aside']['args']['name'] = 'Footer First';
    	$content['2nd Subsidiary Aside']['args']['name'] = 'Footer Second';
    	$content['3rd Subsidiary Aside']['args']['name'] = 'Footer Third';
    	return $content;
    }
    add_filter('thematic_widgetized_areas', 'rename_widgetized_areas');
    
    // Register Fourth Footer Widget Area
    
    function add_fourth_subsidiary(){
        register_sidebar(array(
           	'name' => 'Footer Fourth',
           	'id' => '4th-subsidiary-aside',
           	'before_widget' => '<li id="%1$s" class="widgetcontainer %2$s">',
           	'after_widget' => "</li>",
    	'before_title' => thematic_before_title(),
    	'after_title' => thematic_after_title(),
        ));
    }
    add_action('init','add_fourth_subsidiary');
    
    // Output Fourth Footer Widget Area
    
    function output_fourth_subsidiary(){
    	if ( is_sidebar_active('4th-subsidiary-aside') ) { // there are active widgets for this aside
            echo '<div id="fourth" class="aside sub-aside">'. "\n" . '<ul class="xoxo">' . "\n";
            dynamic_sidebar('4th-subsidiary-aside');
            echo '</ul>' . "\n" . '</div><!-- #fourth .aside -->'. "\n";
    	do_action('widget_area_4th_subsidiary_aside');
    	}
    }
    add_action('thematic_after_third_sub', 'output_fourth_subsidiary');
    Posted 3 years ago #
  5. nice devin. i didn't know thematic_after_third_sub was a hook and have been curious about adding widgets.

    And for the OP... I recently unset a bunch of my widgets too w/ the exact code Devin posted. But kept the page_bottom widget, renamed it and told it to use a different function. I copied its original function from Thematic, but added an extra condition so that it would only show on the front page.

    function rename_widgetized_areas($content) {
    	$content['Page Bottom']['function'] = 'my_page_bottom';
    	return $content;
    }
    add_filter('thematic_widgetized_areas', 'rename_widgetized_areas');
    
    // Re-Define the Page Bottom Widget to only show on the front page
    function my_page_bottom() {
    	if (is_sidebar_active('page-bottom') AND is_front_page()) {
    		echo thematic_before_widget_area('page-bottom');
    		dynamic_sidebar('page-bottom');
    		echo thematic_after_widget_area('page-bottom');
    	}
    }
    Posted 3 years ago #
  6. Hello, Devin.
    I'm reading your comment 1 year after and would like to say you helped me too much.
    Thanks! :-)

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.