Skip to content

Instantly share code, notes, and snippets.

@remi
Created March 30, 2010 13:22
Show Gist options
  • Save remi/349088 to your computer and use it in GitHub Desktop.
Save remi/349088 to your computer and use it in GitHub Desktop.
<?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