Created
March 5, 2013 14:48
-
-
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
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 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