is_tree problem
-
Hey all,
I’m having some trouble getting the is_tree() function to work. I’ve set it up as the codex, and other pages, state, but the values which it to me are always from the else statement of my if argument, regardless of which page i go to.
I’m running my wp installation on a subdirectory of my localhost, could that be a problem?
Here’s what I’ve put into my functions.php:
<?php function is_tree($pid) { // $pid = The ID of the page we're looking for pages underneath global $post; // load details about this page if(is_page()&&($post->post_parent==$pid||is_page($pid))) return true; // we're at the page or at a sub page else return false; // we're elsewhere } ?> <?php if (is_tree("374")) { // if root page is the products page (change id as appropriate) $selection = 'selection_products'; $logoimg = 'images/site/products_logo.gif'; } elseif (is_tree("148")) { // if root page is the shop section $selection = 'selection_shop'; $logoimg = 'images/site/shop_logo.gif'; } elseif (is_tree("382")) { // if root page is the help section $selection = 'selection_help'; $logoimg = 'images/site/help_logo.gif'; } else { $selection = 'selection_home'; $logoimg = 'images/site/home_logo.gif'; } ?>All help appreciated!
nb:
When I get this working I want to make the modification suggested by Marty Tomly so that grandchildren are also selected, but that’s not an issue for now.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘is_tree problem’ is closed to new replies.