How to display all widget areas for a test?

If you work with Thematic for the first time, the most asked question will be, where are all these widget areas located?

You could go to the Widgets section in WP Admin and assign at least one widget to the 13 widget areas. I’m too lazy for this. So I spend some time to create something that eases my life.

Go to WP Admin / Appearance / Thematic Options and hit the ‘Reset Widgets’ button. Then add the following code to your child theme’s functions.php:

function widget_args()
{
	return array (
	'before_widget' => thematic_before_widget(),
	'after_widget'  => thematic_after_widget(),
	'before_title'  => thematic_before_title(),
	'after_title'   => thematic_after_title()
	);
}

function wa_primary_aside()
{
	echo thematic_before_widget_area('primary-aside');
	the_widget('WP_Widget_Text', array('title' => 'Primary Aside', 'text' => 'This is the Primary Aside', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('primary-aside');
}

function wa_secondary_aside()
{
	echo thematic_before_widget_area('secondary-aside');
	the_widget('WP_Widget_Text', array('title' => 'Secondary Aside', 'text' => 'This is the Secondary Aside', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('secondary-aside');
}

function wa_subsidiary_open()
{
	echo '<div id="subsidiary">';
} 

function wa_1st_subsidiary()
{
	echo thematic_before_widget_area('1st-subsidiary-aside');
	the_widget('WP_Widget_Text', array('title' => '1st Subsidiary Aside', 'text' => 'This is the 1st Subsidiary Aside', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('1st-subsidiary-aside');
}

function wa_2nd_subsidiary()
{
	echo thematic_before_widget_area('2nd-subsidiary-aside');
	the_widget('WP_Widget_Text', array('title' => '2nd Subsidiary Aside', 'text' => 'This is the 2nd Subsidiary Aside', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('2nd-subsidiary-aside');
}

function wa_3rd_subsidiary()
{
	echo thematic_before_widget_area('3rd-subsidiary-aside');
	the_widget('WP_Widget_Text', array('title' => '3rd Subsidiary Aside', 'text' => 'This is the 3rd Subsidiary Aside', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('3rd-subsidiary-aside');
}

function wa_subsidiary_close()
{
	echo '</div>';
} 

function wa_index_top()
{
	echo thematic_before_widget_area('index-top');
	the_widget('WP_Widget_Text', array('title' => 'Index Top', 'text' => 'This is the Index Top', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('index-top');
	}

function wa_index_insert()
{
	echo thematic_before_widget_area('index-insert');
	the_widget('WP_Widget_Text', array('title' => 'Index Insert', 'text' => 'This is the Index Insert', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('index-insert');
}

function wa_index_bottom()
{
	echo thematic_before_widget_area('index-bottom');
	the_widget('WP_Widget_Text', array('title' => 'Index Bottom', 'text' => 'This is the Index Bottom', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('index-bottom');
}

function wa_single_top()
{
	echo thematic_before_widget_area('single-top');
	the_widget('WP_Widget_Text', array('title' => 'Single Top', 'text' => 'This is the Single Top', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('single-top');
}

function wa_single_insert()
{
	echo thematic_before_widget_area('single-insert');
	the_widget('WP_Widget_Text', array('title' => 'Single Insert', 'text' => 'This is the Single Insert', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('single-insert');
}

function wa_single_bottom()
{
	echo thematic_before_widget_area('single-bottom');
	the_widget('WP_Widget_Text', array('title' => 'Single Bottom', 'text' => 'This is the Single Bottom', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('single-bottom');
}

function wa_page_top()
{
	echo thematic_before_widget_area('page-top');
	the_widget('WP_Widget_Text', array('title' => 'Page Top', 'text' => 'This is the Page Top', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('page-top');
}

function wa_page_bottom()
{
	echo thematic_before_widget_area('page-bottom');
	the_widget('WP_Widget_Text', array('title' => 'Page Bottom', 'text' => 'This is the Page Bottom', 'filter' => ''), widget_args());
	echo thematic_after_widget_area('page-bottom');
}

add_action('widget_area_primary_aside', 'wa_primary_aside', 10);
add_action('widget_area_secondary_aside', 'wa_secondary_aside', 10);
add_action('widget_area_subsidiaries', 'wa_subsidiary_open', 10);
add_action('widget_area_subsidiaries', 'wa_1st_subsidiary', 30);
add_action('widget_area_subsidiaries', 'wa_2nd_subsidiary', 50);
add_action('widget_area_subsidiaries', 'wa_3rd_subsidiary', 70);
add_action('widget_area_subsidiaries', 'wa_subsidiary_close', 90);
add_action('widget_area_index_top', 'wa_index_top', 10);
add_action('widget_area_index_insert', 'wa_index_insert', 10);
add_action('widget_area_index_bottom', 'wa_index_bottom', 10);
add_action('widget_area_single_top', 'wa_single_top', 10);
add_action('widget_area_single_insert', 'wa_single_insert', 10);
add_action('widget_area_single_bottom', 'wa_single_bottom', 10);
add_action('widget_area_page_top', 'wa_page_top', 10);
add_action('widget_area_page_bottom', 'wa_page_bottom', 10);

This code will not assign any widget to the widget areas. So it’s nothing to test any logic behind the widgets or widget areas. It’ll simulate the process using the_widget().

The link id and the class are not working properly. I could make both items static and fix this issue, but I left this part as it is, if you want to filter thematic_before_widget(), thematic_after_widget(), thematic_before_title() and thematic_after_title.

This should be good enough to get a feeling for the locations of the several widget areas and to test the design / layout of your child theme.

This entry was posted in Layout, Widget Area and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. Posted February 28, 2010 at 4:38 pm | Permalink

    Chris- Impressed as always, very clever. I’ll be putting this to good use. FYI, your double arrow operators have been accidentally encoded in the code above.

    -Gene

    • Posted February 28, 2010 at 7:09 pm | Permalink

      Thanks a lot! This seems to be a bug in ‘After the Deadline’.

      -Chris

  2. shanoboy
    Posted August 20, 2010 at 11:27 pm | Permalink

    I’m stumped on how to actually call the individual widget areas so that I can style each individually. Any help there? Cant find anything in the Thematic forum.

    Thanks!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

More in Layout Widget Area (3 of 2 articles)