I came across this and it was very helpful, thank you. To fill the space when a category or tag is not being shown, I added the option to use the word "Recent."
Code: Select all
<?php
// Check if the user is browsing a category
if ($WHERE_AM_I=='category') {
// Get the category key from the URL
$categoryKey = $url->slug();
// Create the Category-Object
$category = new Category($categoryKey);
// Print the category name
echo $category->name();
// Print the category description
echo $category->description();
}
// Check if the user is browsing a tag
elseif ($WHERE_AM_I=='tag') {
// Get the tag key from the URL
$tagKey = $url->slug();
// Create the Tag-Object
$tag = new Tag($tagKey);
// Print the tag name
echo $tag->name();
}
// Show this title if none of the other are being used
else {
echo "Recent";
}
?>