Skip to content

Instantly share code, notes, and snippets.

@jarednova
Last active August 7, 2016 16:09
Show Gist options
  • Save jarednova/b9aa424c2dd2c01b40114e65f972c6a8 to your computer and use it in GitHub Desktop.
Save jarednova/b9aa424c2dd2c01b40114e65f972c6a8 to your computer and use it in GitHub Desktop.
Aldenta Images
<?php
class Aldenta_Post extends TimberPost {
function child_images() {
$thumb_id = get_post_thumbnail_id($this->ID);
return get_children(array('post_parent'=>$this->ID, 'post_status' => 'inherit', 'post_type' => 'attachment',
'post_mime_type' => 'image', 'order'=> 'ASC', 'orderby' => 'menu_order ID', 'exclude'=>$thumb_id));
}
}
<?php
$context = Timber::get_context();
$post = new AldentaPost();
$context['post'] = new Aldenta_Post();
Timber::render('single.twig', $context):
<div>
{% for image in post.child_images %}
{% if loop.index %2 != 0 %}
<div class="product">
<a href="{{ image.post_excerpt }}" class="img-wrap product-image">
<span class="product-price">{{ image.alt }}</span>
<img src="{{ image.src }}" />
</a>
<h3>{{ image.title }}</h3>
<div>
<p>{{ post.content }}</p>
</div>
</div>
{% endif %}
{% endfor %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment