Categorized index
-
- Jr. Bludit
- Posts: 6
- Joined: Sun Feb 26, 2023 12:15 am
- Has thanked: 3 times
- Been thanked: 1 time
So, now my homepage is showing all posts no matter what category I set for them.
I want to divide them in 2 separated divs.
One for posts that has "works" category applied and one for the one that has "articles" category.
Something like that:
<h1> Works </h1>
<div> works in here </div>
<h1> Articles </h1>
<div> articles here </div>
- Edi
- Site Admin
- Posts: 3018
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 39 times
- Been thanked: 60 times
- Contact:
There is a tutorial for this in the documentation:
https://docs.bludit.com/en/dev-snippets/categories
https://docs.bludit.com/en/dev-snippets/categories
-
- Jr. Bludit
- Posts: 6
- Joined: Sun Feb 26, 2023 12:15 am
- Has thanked: 3 times
- Been thanked: 1 time
so it would be this:Edi wrote: ↑Mon Feb 27, 2023 5:05 pm There is a tutorial for this in the documentation:
https://docs.bludit.com/en/dev-snippets/categories
Code: Select all
List all pages related to a particular category:
<?php
// Category key
$categoryKey = 'example';
// The category is an Category-Object
$category = getCategory($categoryKey);
// Print the category name
echo 'Category name: ' . $category->name();
// Print the pages title related to the category "example"
foreach ($category->pages() as $pageKey) {
$page = new Page($pageKey);
echo $page->title();
}
?>