0
我想爲Bootstrap做一個最近的帖子傳送帶。該PHP似乎是輸出正確的HTML,但由於某種原因,傳送帶不會循環。WordPress的Bootstrap旋轉木馬指標不騎自行車
<div class="col-sm-6 col-md-9">
<div class="section-title">
<h1>Most Recent Post</h1>
</div>
<?php
// Get posts (tweak args as needed)
$i=0;
$incNum = 0;
$args = array(
'post_type' => 'post',
'posts_per_page' => 4,
'orderby' => "date",
'order' => "desc"
);
$posts = get_posts($args);
?>
<div id="recent-post-carousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php foreach (array_chunk($posts, 4, true) as $posts) : ?>
<?php echo('<li data-target="#recent-post-carousel" data-slide-to="'.$incNum.'"'.($incNum == 0 ? 'class="active"':'class').'></li>');
$incNum++;
?>
<?php endforeach; ?>
</ol>
<div class="carousel-inner">
<?php
// Get posts (tweak args as needed)
$i=0;
$incNum = 0;
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'orderby' => "date",
'order' => "desc"
);
$posts = get_posts($args);
?>
<?php foreach (array_chunk($posts, 4, true) as $posts) : ?>
<div class="item <?php if ($i==0){echo 'active';}?>">
<div class="row">
<?php foreach($posts as $post) : setup_postdata($post); ?>
<div class="col-sm-6 post-fix">
<div class="single-post ">
<div class="pull-left post-image">
<a href="#">
<?php the_post_thumbnail('full'); ?>
<i class="fa fa-angle-right"></i>
</a>
</div>
<div class="pull-right post-details">
<p class="post-date">03 Dec 2014</p>
<p><?php echo $i?></p>
<a href="#"><h5><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h5></a>
<span>John doe</span>
<p><?php echo substr(get_the_excerpt(), 0,99).' [...]'; ?></p>
</div>
</div>
</div>
<?php $i++ ?>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
編輯:我現在更新它它的工作原理,但有重複的帖子得到兩次更有效的方法?