Created
March 30, 2010 13:22
-
-
Save remi/349088 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// Détermine si la page "$id" a comme ancêtre la page "$ancestor_id" | |
function is_page_ancestor( $id, $ancestor_id ) { | |
$p = get_post( $id ); | |
while ( $p->post_parent ) { | |
if ( $p->post_parent == $ancestor_id ) { return true; } | |
$p = get_post( $p->post_parent ); | |
} | |
} | |
// Retourne le plus "haut" parent de la page "$id" | |
function get_page_highest_ancestor( $id ) { | |
$p = get_post( $id ); | |
while ( $p->post_parent ) { | |
$p = get_post( $p->post_parent ); | |
} | |
return $p->ID; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment