Created
April 23, 2014 15:16
-
-
Save ivandoric/11219508 to your computer and use it in GitHub Desktop.
wordpress: is_tree function - Check if on certain page or on page children function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function is_tree($pid) { | |
global $post; | |
$anc = get_post_ancestors( $post->ID ); | |
foreach($anc as $ancestor) { | |
if(is_page() && $ancestor == $pid) { | |
return true; | |
} | |
} | |
if(is_page()&&(is_page($pid))) | |
return true; | |
else | |
return false; | |
}; | |
/* Use like this */ | |
if(is_tree(PAGE_ID)){ | |
// something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment