Skip to content

Instantly share code, notes, and snippets.

@jolantis
Forked from craigmdennis/kirby-title.php
Last active August 29, 2015 14:11
Show Gist options
  • Save jolantis/bf3677ac0d969b5d8364 to your computer and use it in GitHub Desktop.
Save jolantis/bf3677ac0d969b5d8364 to your computer and use it in GitHub Desktop.
<?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