• Resolved Doodlebee

    (@doodlebee)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Doodlebee

    (@doodlebee)

    Crap. Nevermind. I’m uttery stupid. I wasn’t paying attention and had placed the code *outside* of the Loop. Put it in, and it works fine.

    Thank you SO much for taking a minute to follow up on your own post. You just ended 3 days of frustration as to why my child page navigation was not working properly. I posted about it on another thread here but like you, got no answer. ?? Anyway just wanted to say thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Testing for child pages isn’t working’ is closed to new replies.