This is how i get a list of all post or all posts of one tag:
Code: Select all
if ($Url->whereAmI() == 'blog') {
// list all posts
$totalPublishedPosts = $dbPosts->numberPost(true);
$posts = buildPostsForPage(0, $totalPublishedPosts, true, false);
} elseif ($Url->whereAmI() == 'tag') {
$tagKey = $Url->slug();
$totalPublishedPosts = $dbTags->countPostsByTag($tagKey);
$posts = buildPostsForPage(0, $totalPublishedPosts, true, $tagKey);
}
Code: Select all
$totalPublishedPosts = $dbPosts->numberPost(true);
$posts = buildPostsForPage(0, $totalPublishedPosts, true, false);
foreach ($posts as $Post) {
if ( $Post->tags() != 'DONTLISTME' ) {
echo '<a href="'.$Post->permalink() .'">';
if($Post->coverImage()) {
echo '<img src="'.$Post->coverImage().'" alt="Cover Image">';
} else {
echo '<h4>'.$Post->title().'</h4>';
}
echo '</a>';
}
}
This i how a build a list with posts tagged with two keys (or more, just add conditions):
Code: Select all
$totalPublishedPosts = $dbPosts->numberPost(true);
$posts = buildPostsForPage(0, $totalPublishedPosts, true, false);
// build a list of filtered posts
$filteredPosts = [];
foreach ($posts as $Post) {
if ( (strpos($Post->tags(), 'TAG1') !== false) || (strpos($Post->tags(), 'TAG2') !== false)) {
$filteredPosts[] = $Post;
}
}
Have fun!
matto
------------------------------------
Hi!
I am creating a bludit theme and need too list all posts.
Code: Select all
foreach($posts as $Post) {
if($Post->published()) {
echo '<h1><a href="'.$Post->permalink().'">'.$Post->title().'</a></h1>';
}
}
What is correct way, to do this?
greetings