0

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
        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
};

Thanks Furqan Khyraj

1
  • Can you rephrase the question? I'm not sure I understand. – Brooke. Sep 26 '11 at 6:38
1

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));
 }
0

I do not understand your question that good but check out http://codex.wordpress.org/Function_Reference/get_pages.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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