How to show the current catorgy and tags for a page - php

Post Reply
rduinmaijer
Jr. Bludit
Posts: 1
Joined: Sat Nov 17, 2018 9:52 pm

How can I show the current catorgy and tags for a page?

I found something like this in the docs:
<?php
$items = getCategories();

foreach ($items as $category) {
// Each category is an Category-Object
echo 'Category name: ' . $category->name();


But obviously it will show all categories and just the onces that belong to a page.
User avatar
bayerberg
Master Bludit
Posts: 139
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

Tags

Code: Select all

if ($page->tags(true)) {
echo'<ul>';
foreach ($page->tags(true) as $tagKey=>$tagName) {
echo '<li><a href="'.DOMAIN_TAGS.$tagKey.'" rel="tag">'.$tagName.'</a></li>';
 }
echo'</ul>';
}
Categories

Code: Select all

if ($page->category()) {
 echo ' <a href="'.DOMAIN_CATEGORIES.$page->categoryKey().'">'.$page->category().'</a> ';
};
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
Post Reply