Hallo zusammen,
ich habe eine Frage zu dem Post Format Gallery.
Ich bin gerade dabei, für die verschiedenen Post Formate eine eigenen content-'post-format'.php anzulegen.
Ich habe folgendes im Netz schon gefunden, aber ich komme irgendwie nicht dahinter, warum meine Bilder nicht ausgegeben werden.
template.php
PHP
function canvas_get_attachment($num = 1)
{
$output = '';
if (has_post_thumbnail() && $num == 1):
$output = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())); else:
$attachments = get_posts(array(
'post_type' => 'attachment',
'posts_per_page' => $num,
'post_parent' => get_the_ID(),
));
if ($attachments && $num == 1):
foreach ($attachments as $attachment):
$output = wp_get_attachment_url($attachment->ID);
endforeach; elseif ($attachments && $num > 1):
$output = $attachments;
endif;
wp_reset_postdata();
endif;
return $output;
}
function canvas_get_slides($attachments)
{
$output = array();
$count = wp_count_attachments() - 1;
for ($i = 0; $i <= $count; ++$i):
$output[$i] = array(
'url' => wp_get_attachment_url($attachments[$i]->ID),
);
endfor;
return $output;
}
Alles anzeigen
contact-gallery.php
PHP
<div class="entry-image fslider" data-smooth-height="false">
<div class="flexslider">
<div class="slider-wrap">
<?php
$attachments = canvas_get_slides( canvas_get_attachment(7) );
foreach( $attachments as $attachment ) {?>
<div class="slide"><img class="lazy" data-src="<?php echo $attachment['url']; ?>" alt="Slider 1"></div>
<?php } ?>
</div>
</div>
</div>
Alles anzeigen
Weiß jemand woran es liegen könnte?
Danke und Gruß
Sven