Docs: Posts

Posts

The Blog's posts in a theme: posts and post.

posts($query = []) #

Live posts in the pages() envelope (E). Each item is {id, title, url, excerpt, image, published, updated, tags, author, current}. Options: limit (1 to 50), page, offset, tag, exclude, order. A draft, or a post that is not yet due, is never listed. author is a display name, or empty. Without the Blog you get error: 'module'.

<?php foreach ($this->posts(['limit' => 3])['items'] as $p): ?>
  <a href="<?= $p['url'] ?>"><?= $p['title'] ?></a>
  <time datetime="<?= $this->date($p['published'], 'iso') ?>"><?= $this->date($p['published']) ?></time>
<?php endforeach; ?>

post() #

The post this page shows, as a posts() item plus body (M), else null.

<?php if ($post = $this->post()): ?><h1><?= $post['title'] ?></h1><?= $post['body'] ?><?php endif; ?>