Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

here is Hierarchy

Parent (id=34) Child Child of child-1 Child of child-2 Child of child-3 Child of child-4

I am at child of child, i Just want to show sibblings of child of child if parent is '34', like this

  • Child of child-1
  • Child of child-2
  • Child of child-3
  • Child of child-4

I used the below function in function.php, but its not working properly

    function is_tree($pid) {      // $pid = The ID of the page we're looking for pages underneath
        global $post;         // load details about this page
               return true;   // we're at the page or at a sub page
               return false;  // we're elsewhere

Thanks Furqan Khyraj

share|improve this question
Can you rephrase the question? I'm not sure I understand. – BandonRandon Sep 26 '11 at 6:38

2 Answers 2

The page object has 2 properties: post_parent which is the parent page, and ancestors, which is array of all of the page's ancestors in the tree.

 $currentPageId = get_the_ID();
 $page = get_page($currentPageId);
 if (in_array(34, $page->ancestors)) {
      $siblings = get_pages(array('child_of' => $page->post_parent));
share|improve this answer

I do not understand your question that good but check out

Will get_pages( array ( 'child_of' => 34 ) ); help?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.