Search the blog

If you use $page->children() in ProcessWire it will only get direct descendents. If you want all descendents you don’t need to interate through all children, grandchildren, etc. Like $pages, each $page has a find() function. So, all you need to do is something like this:

$page->find('template=page')

This will get all descendents that have the template “page”. Obviously, you should change the selector to suit your use case.

Tim Bennett is a Leeds-based web designer from Yorkshire. He has a First Class Honours degree in Computing from Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.