Different sidebars for certain pages not working.
-
Hi all, I have this code that is supposed to display certain sidebars in certain pages. I got it from the codex this is my modified version:
<!-- begin sidebar --> <div class="sidebar"> <?php // let's generate info appropriate to the page being displayed if ( is_home() ) { // we're on the home page, so let's show a list of all top-level categories echo "<ul>"; wp_list_cats( 'optionall=0&sort_column=name&list=1&children=0' ); echo "</ul>"; // we're looking at a single page, so let's not show anything in the sidebar } elseif ( is_page('') ) { // we're looking at a static page. Which one? if ( is_page( '211' ) || '211' == $postid->post_parent){ // our Sacramento Studio page. !function_exists('dynamic_sidebar') || !dynamic_sidebar(1); } elseif ( is_page( 'San Francisco' ) ) { //our San Francisco Page !function_exists('dynamic_sidebar') || !dynamic_sidebar(2); } else { // catch-all for other pages echo "<p>OOPS! No Side Bars Defined For This Page.</p>"; } } else { // catch-all for everything else (archives, searches, 404s, etc) echo "<p>OOPS! No Side Bars Defined For This Page.</p>"; } // That's all, folks! ?> </div> <!-- end sidebar -->
This code switches between sidebars depending on the page it’s on. I’ve got it to work perfectly until I wanted child pages to display the parent’s sidebar using this particular piece of code:
if ( is_page( 'Sacramento' ) || '211' == $postid->post_parent){ // our Sacramento Studio page. !function_exists('dynamic_sidebar') || !dynamic_sidebar(1);
Well that displays the appropriate sidebar in the parent page but not the child pages. Any help is greatly appreciated!
Thanks!
- The topic ‘Different sidebars for certain pages not working.’ is closed to new replies.