How to show the current catorgy and tags for a page - php
-
- 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.
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.
- bayerberg
- Master Bludit
- Posts: 141
- Joined: Wed Jun 07, 2017 1:05 pm
- Location: London, UK
- Has thanked: 9 times
- Been thanked: 10 times
- Contact:
Tags
Categories
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>';
}
Code: Select all
if ($page->category()) {
echo ' <a href="'.DOMAIN_CATEGORIES.$page->categoryKey().'">'.$page->category().'</a> ';
};