方便的小功能
function is_child_of($parent) {
global $post;
if ( $post->post_parent == $parent){
return true
}else{
$curent_parent = $post->post_parent;
$dec = false;
while ($curent_parent > 0){
$p = get_post($curent_parent);
$curent_parent = $p->post_parent;
if ($curent_parent > 0){
if ($curent_parent == $parent){
return true;
}
}
}
return false;
}
用法:检查current是否是ID为22的页面的子级
if (is_child_of(22)){
//its a child of 22
}