Adding is_tree functon to WordPress


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.