Ok, lets break it down, all the links are going to be to the source code.
wp_list_pages()
only uses get_pages()
to (sic!) get pages, walk_page_tree()
does the hierarchical structuring inside it. The further course of the process goes Walker_Page
– and the generic Walker
of course -, unless a custom walker is used. Inside walk_page_tree()
you will see, the walkers walk
method is called, which subsequently calls the display_element
method. Mainly in the display_element
, but also in the walk
, method you find the handling of the depth.
To make it short: the depth is handled by iterating, display_element
calls itself until the end or the given depth
parameter.