Skip to content

Instantly share code, notes, and snippets.

@jartes
Created March 5, 2013 14:48
Show Gist options
  • Save jartes/5090783 to your computer and use it in GitHub Desktop.
Save jartes/5090783 to your computer and use it in GitHub Desktop.
[WordPress] Obtener el número de padres de una página. Si no tiene, n = 0. Para posts, igual pero cambiando get_page por get_post
function get_page_parent_number( $pagina = null ) {
$n = 0;
while ( $pagina->post_parent != 0 ) {
$pagina = get_page( $pagina->post_parent );
++$n;
}
return $n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment