Posted By

klagraff on 08/16/12


pages wordpress is tree functionsphp

Versions (?)

Adding is_tree functon to WordPress

 / Published in: PHP

Add this to functions.php to enable the page-child function is_tree

  1. function is_tree($pid) { // $pid = The ID of the page we're looking for pages underneath
  2. global $post; // load details about this page
  3. if(is_page()&&($post->post_parent==$pid||is_page($pid)))
  4. return true; // we're at the page or at a sub page
  5. else
  6. return false; // we're elsewhere
  7. };

Report this snippet  

You need to login to post a comment.