Blog loop - adampatterson/Tentacle GitHub Wiki

Because blog posts are generally in chronological order as well as paginated we need to loop the blog posts in order to display them.

This code can be found in template-blog.php

<? foreach ($posts as $post): ?>
	<div class="blog-article">
		<h2 class="title"><a href="<?= BASE_URL.$post->uri ?>"><?= $post->title?></a></h2>
		<small>Posted in: 
			<? foreach( $category->get_relations( $post->id ) as $relation ): ?>
				 <a href="#<?=$relation->slug ?>"><?= $relation->name ?></a>
			<? endforeach; ?>
		</small>
		<?= render_content( $post->content );?>
	</div>
<? endforeach;?>

Each individual post is rendered by default using the type-post.php template. You can add more than one post type.

See Template Structure for more information on post types.

⚠️ **GitHub.com Fallback** ⚠️