Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Show all parent page titles in the HTML `<title>` tag using Kirby
// Start off with an empty $title
$title = '';
// Get all the parents (except the homepage) and reverse the array
$parents = $site->breadcrumb()->not('home')->flip();
// Iterate over the array
foreach ($parents AS $parent) :
// Add each title to a variable (with a pike as a separator)
$title .= $parent->title() . ' | ';
// Add the site title last
$title .= $site->title();
<!-- Echo the title variable inside the <title> tag -->
<title><?php echo $title; ?></title>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.