Lave array med billeder fra indlæg i WordPress?
Hej EksperterJeg har dette array som henter hvert indlæg ud på en lang liste. Nu vil jeg gerne have dem tilføjet til en JavaScript karussel. Problemet er at det første billede skal have class'et 'item active'.
Her er den kode som får den listet ud:
<?php
$args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) { ?>
<img src="<?php bloginfo('template_url'); ?>/timthumb.php?w=320&h=213&zc=1&src=<?php echo wp_get_attachment_url( $attachment->ID , false ); ?>" alt="<?php the_title(); ?>" />
<?php }
} ?>
Her er karusselen som koden skal implementeres i:
<div id="this-carousel-id" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<img src="http://domain.com/timthumb.php?w=320&h=213&zc=1&src=http://domain.com/picture.jpg" />
</div>
<div class="item">
<img src="http://domain.com/timthumb.php?w=320&h=213&zc=1&src=http://domain.com/picture.jpg" />
</div>
<div class="item">
<img src="http://domain.com/timthumb.php?w=320&h=213&zc=1&src=http://domain.com/picture.jpg" />
</div>
</div>
</div>
Håber at nogen kan hjælpe mig lidt videre.
På forhånd tak og god aften til jer alle...
/Martin