【发布时间】:2014-12-26 05:50:14
【问题描述】:
好的,我有一个投资组合页面。每个投资组合项目都附有缩略图。我想要的是从第一篇文章中打印出第一个缩略图两次。一个在开头,另一个在结尾。比如:image_1, image_2, image_3, image_4 & 然后是 image_1。
我的代码是:
<div class="main-interior portfolio" id="portfolio-big-pics" style="display: block;">
<?php $args = array( 'post_type' => 'portfolio', 'order' => 'dsc');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php $extraFirstClass = $loop->current_post == '0' ? ' main-image-porfolio-main' : ''; ?>
<?php
$attributes = array(
"class" => "main-image portfolio " . $extraFirstClass,
"id" => "photo_{$post->ID}",
);
the_post_thumbnail("portfolio_thumb", $attributes);
?>
<?php endwhile; ?>
<?php rewind_posts(); ?>
<div class="portfolio-box">
<h5>Portfolio</h5>
<ul class="item-list" id="portfolio-list">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" rel="<?php echo $post->ID; ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
</div>
</div>
我该怎么做?
【问题讨论】: