0
こんにちは私はWordPressでwhileループを使用しています。ループの最初のインスタンスにアクティブなクラスを追加していますが、これはうまく動作しますが、同じインスタンスが再びアクティブクラスなしで繰り返されます。Wordpressループが2回繰り返される
ここに私のコードですが、どんな助けでも大歓迎です。
<div class="carousel-inner" role="listbox">
<?php
query_posts(array('post_type' => 'deal','dealtype' => 'deals'));
while (have_posts()) : the_post();
?>
<?php if($wp_query->current_post == 0 && !is_paged()) { ?>
<div class="item active">
<div class="row">
<div class="col-md-6 col-md-offset-1 col-sm-6 col-sm-offset-1">
<?php
$thumb_id = get_field('featured_image');
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
$thumb_url = $thumb_url_array[0];
?>
<img src="<?php echo $thumb_url; ?>" class="img-responsive" alt="" />
</div>
<div class="col-md-4 col-sm-4">
<div class="featuredContent">
<div class="contentTitle">
<h2><?php echo get_the_title(); ?> </h2>
</div>
<div class="contentDetails">
<p><?php echo get_field('sub_title'); ?>
</p>
</div>
<?php if(get_field('max_amount')) { ?>
<div class="contentDetails">
<p>Up to
<?php the_field('max_amount'); ?>
Shares</p>
</div>
<?php } ?>
<!--
<div class="contentLink">
<p><a href="#">invest now</a></p>
</div>
<div class="contentLink">
<p><a href="#">follow offering</a></p>
</div>
-->
</div>
</div>
</div>
</div>
<?php } ?>
<div class="item">
<div class="row">
<div class="col-md-6 col-md-offset-1 col-sm-6 col-sm-offset-1">
<?php
$thumb_id = get_field('featured_image');
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
$thumb_url = $thumb_url_array[0];
?>
<img src="<?php echo $thumb_url; ?>" class="img-responsive" alt="" />
</div>
<div class="col-md-4 col-sm-4">
<div class="featuredContent">
<div class="contentTitle">
<h2><?php echo get_the_title(); ?> </h2>
</div>
<div class="contentDetails">
<p><?php echo get_field('sub_title'); ?>
</p>
</div>
<?php if(get_field('max_amount')) { ?>
<div class="contentDetails">
<p>Up to
<?php the_field('max_amount'); ?>
Shares</p>
</div>
<?php } ?>
<!--
<div class="contentLink">
<p><a href="#">invest now</a></p>
</div>
<div class="contentLink">
<p><a href="#">follow offering</a></p>
</div>
-->
</div>
</div>
</div>
</div>
<?php endwhile; // end of the loop. ?>
</div>