PHP webdeveloper and frontend developer




Get the depth of the current page in WordPress

Category : PHP, Wordpress · by Jun 26th, 2013

If you want to get the level of the current page in WordPress you can use this 

 This function will echo the depth of the current page. If the depth returned is zero then you’re on a parent page.

SHARE :

(1) Comment

jonathan
4 years ago · Reply

Or you could use something like this:

$ancestors=get_post_ancestors($post->ID);
$root=count($ancestors)-1;

Leave a Reply

Your email address will not be published. Required fields are marked *


s