Testing for child pages isn’t working
-
I’m trying to test for child pages of a particular parent. I’ve looked through the forums, and in the codex, and I’ve found the same answer for what I’m trying to do each time – however it’s simply not working. Basically, I want a dropdown list to show up if the Page is ID of 10, or a child of that page ID. So I have this in my page.php file:
<?php global $post; if(is_page('10') || $post->post_parent=="10") { ?> stuff here <?php } ?>
Everything I can find will indicate this should work. But it’s not – only page 10 is showing the “stuff here”. I echoed out the $post_parent part, to see what was being returned (like so):
<?php global $post; $thisis = $post->post_parent; echo $thisis; ?>
And it returns a value of “0” on the subpages. (And yes, they *are* children of 10). Isn’t “0” the value returned if it’s a parent page?
Is there another method for testing if a page is a child? This one’s driving me nuts.
- The topic ‘Testing for child pages isn’t working’ is closed to new replies.