Posted on: March 18, 2010 by Chris Coyier
Have a bunch of different areas you wish to declare as a widgetized area? Save repetative code by creating a quick array of their names, then loop through that array calling the register_sidebar() function on each one. Elementary PHP stuff here, but hey, it just saved me quite a few lines of code in a widget-heavy theme I am working on.
if ( function_exists('register_sidebar') ) {
$allWidgetizedAreas = array("Homepage Left", "Homepage Right", "Sidebar One", "Movies", "Admin");
foreach ($allWidgetizedAreas as $WidgetAreaName) {
register_sidebar(array(
'name'=> $WidgetAreaName,
'before_widget' => '<div id="%1$s" class="widget %2$s left half">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
}
}
Keep Reading
Posted on: March 16, 2010 by Jeff Starr
Most blogs display their content in single columns, but it’s also possible to display content in multiple columns. Multiple-column layouts are perfect for newspaper and magazine-style themes. Here are six ways of getting the job done.
1. Using CSS3 and progressive enhancement
I think the easiest way to display your content in multiple columns is to apply a little CSS3 in progressively enhancing fashion. Let’s say you have the following markup:
<div class="content">
<p>Lorem ipsum..</p>
<p>Lorem ipsum..</p>
<p>Lorem ipsum..</p>
</div>
Keep Reading
Posted on: March 12, 2010 by Chris Coyier
The post_class() function in WordPress is pretty darn useful. It is used like this, in most templates, in a wrapping div of all the content you are outputting:
<div <?php post_class() ?> id="post-< ?php the_ID(); ?>">
<!-- Post stuff -->
</div>
I was in a circumstance where I wanted to add an additional class to what that was outputting. My thought process went like this:
- Arg. I guess I’m going to have to write a function to filter the output of that function. Let’s begin the research.
- Wait. I bet that function has an alternate that returns a string rather than echos it. I’ll just use that, and echo it out along with my own custom class.
- Double wait. I bet those smart WordPress folks have thought of this…
Keep Reading