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

Sat Nov 17, 2018 9:55 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: 71
Joined: Wed Jun 07, 2017 1:05 pm

Tue Nov 20, 2018 1:36 pm

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> ';
};
i do things, check them out on behance | check out startups undiluted - london's startup ecosystem
Post Reply