Last active
August 29, 2015 14:10
-
-
Save craigmdennis/a597a9c4f043e91b58dd to your computer and use it in GitHub Desktop.
Show all parent page titles in the HTML `<title>` tag using Kirby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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