Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannyconnolly/fd18584d02c898b5fd91 to your computer and use it in GitHub Desktop.
Save dannyconnolly/fd18584d02c898b5fd91 to your computer and use it in GitHub Desktop.
Check if page is parent, child in wordpress
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
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment