On my WordPress site, I want to display a list of pages in the current site section. It needs to get different levels of pages depending on what level in the hierarchy the current page resides.
For instance:
- Top level page: the list shouldn’t display at all.
- Second level page: the list should display only child pages of the current page.
- Third level page: the list should display sibling pages and child pages.
What is the simplist way to find out what level of the heirarchy the current page is on?
The simplest way I’ve found is:
This simply gives you a number indicating the depth of the current page. 1 is top level, 2 is second level, etc. Then you can switch code based on the number as such: