One small step for man; a slightly bigger step for Cole
I just figured out a way to assign my dynamic sidebars for each section a little better/easier/simpler than how I was doing it before. I was also able to delete 4 or so template files. All in all? Not a miracle or anything but it took a little experimentation and I’m quite proud!
Essentially, instead of calling one sidebar in all places, I ask it to call a sidebar for a page and all its children like so:
<?php
if ( is_page(‘pagename’) || $post->post_parent == ‘parentid’) {
get_sidebar(‘sidebar’);
} elseif (is_page(‘page2name’) || $post->post_parent == ‘parent2id’) {
get_sidebar(‘sidebar2′);
} else {
get_sidebar();
}
?>
Tags: code, php, sidebars, wordpress
This entry was posted on Saturday, November 14th, 2009 at 1:07 am and is filed under Site Updates. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.
