thanks for your help. Reall appreciated.
I added your print_r code to my page (for anyone else that needs it, the actual code you need to put in the page is this: <?php print_r($post); ?>
On my subpage i get this:
stdClass Object ( [ID] => 146 [post_author] => 1 [post_date] => 2011-07-26 12:44:02 [post_date_gmt] => 2011-07-26 12:44:02 [post_content] => CONTENT REMOVED FOR THIS FORUM [post_title] => Nuclear Energy [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => nuclear-energy [to_ping] => [pinged] => [post_modified] => 2011-07-26 14:55:32 [post_modified_gmt] => 2011-07-26 14:55:32 [post_content_filtered] => [post_parent] => 131 [guid] => https://XXX/?page_id=146 [menu_order] => 0 [post_type] => page [post_mime_type] => [comment_count] => 0 [ancestors] => Array ( [0] => 131 ) [filter] => raw )
I then added snippet 4 to my functions .php and altered my sidebar code to this (i added some code to test the tree code as well – see below):
<?php
echo "<p>is page 'what-we-do' = " . is_page( 'what-we-do' ) . "</p>";
echo "<p>post parent = " . $post->post_parent . "</p>";
echo "<p>is tree = " . is_tree( '131' ) . "</p>";
?>
<?php
if ( is_tree( '131' ) )
{
if ( ! dynamic_sidebar('What We Do Sidebar') ) : endif;
}
else
{
if ( ! dynamic_sidebar('Main Sidebar') ) : endif;
}
?>
When I’m on my page 131 I get the correct sidebar and the following info about it:
is page ‘what-we-do’ = 1
post parent = 0
is tree = 1
But when I’m on my subpage of 131 (the nuclear energy page listed above I get this:
is page ‘what-we-do’ =
post parent = 0
is tree =
even thought it is a subpage of page 131!
SO now I’m wondering if one of my multiple loops on the page is doing something odd to my conditional statements? I struggle with multiple loops so there’s a chance i’ve not done it right. Would that have this effect?
thank you in advance