Last active
August 7, 2016 16:09
-
-
Save jarednova/b9aa424c2dd2c01b40114e65f972c6a8 to your computer and use it in GitHub Desktop.
Aldenta Images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$context = Timber::get_context(); | |
$post = new AldentaPost(); | |
$context['post'] = new Aldenta_Post(); | |
Timber::render('single.twig', $context): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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