The Scrolls

Your Daily Proclamation at Her Realm

Posts Tagged ‘php’

One small step for man; a slightly bigger step for Cole

Comments Off

November 14th, 2009 Posted 1:07 am

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: , , ,
Posted in Site Updates