Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Last active August 29, 2015 14:10
Show Gist options
  • Save craigmdennis/a597a9c4f043e91b58dd to your computer and use it in GitHub Desktop.
Save craigmdennis/a597a9c4f043e91b58dd to your computer and use it in GitHub Desktop.
Show all parent page titles in the HTML `<title>` tag using Kirby
<?php
// 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() . ' | ';
endforeach;
// 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