Created
March 2, 2014 07:28
-
-
Save yokotak0527/9303216 to your computer and use it in GitHub Desktop.
後で書き直し
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
// ============================================================================= | |
// 指定された固定ページの親子関係か否か | |
// ============================================================================= | |
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