Instantly share code, notes, and snippets.

Embed
What would you like to do?
後で書き直し
// =============================================================================
// 指定された固定ページの親子関係か否か
// =============================================================================
function _in_page($val = ""){
global $post;
$valArr;
$val = preg_replace('/\/$/', '', $val);
$val = preg_replace('/^\//', '', $val);
$valArr = preg_split("/\//", $val);
$slugArr = array();
$not = false;
if(is_page()){
$page = get_page($post->ID);
while($page->post_parent){
$page = get_page($page->post_parent);
$slugArr[] = $page->post_name;
}
$slugArr = array_reverse($slugArr);
for($i=0,$l=count($valArr); $i<$l ;$i++){
if($slugArr[$i] != $valArr[$i]) $not = true;
}
if($not){
return false;
}else{
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment