Return this page’s parent pages, or the parent pages matching the given selector.
This method returns all parents of this page, in order. If a selector is specified, they will be filtered by the selector.
Examples
// Render breadcrumbs
foreach($page->parents() as $parent) {
echo "<li><a href='$parent->url'>$parent->title</a></li>";
}
// Return all parents, excluding the homepage
$parents = $page->parents("template!=home");
Usage
// basic usage
$items = $page->parents();
// usage with all arguments
$items = $page->parents($selector = '');
Arguments
Name | Type(s) | Description |
---|---|---|
selector (optional) | string, array | Optional selector string to filter parents by. |
Return value
PageArray
All parent pages, or those matching the given selector.
API reference based on ProcessWire core version 3.0.137