我试图在旋转木马中获得最新的WordPress帖子,我收到没有错误,但也没有结果!WordPress最新帖子轮播
这里是我使用的代码...
<div class = "jumbotron">
<div id = "carousel-example-generic"
class = "carousel slide"
data-ride = "carousel">
<?php
$my_query = new WP_Query();
$my_query -> query('showposts = 12');
$x == 0;
$do_not_duplicate = $post -> ID;
echo ' <ol class = "carousel-indicators">\n';
while ($my_query -> have_posts()) : $my_query->the_post();
echo ' <li data-target = \"#carousel-example-generic\" data-slide-to = "' .
$x .
'"';
$x++;
if($x == 0)
{
echo ' class = \"active\"';
}
echo '>\n' .
' </li>\n';
endwhile;
echo ' </ol>\n';
?>
<!-- Carousel items -->
<div class="carousel-inner">
<?php
$x == 0;
while ($my_query -> have_posts()) : $my_query -> the_post();
?>
<div class = "<?php if ($x == 0){ echo 'active item';} else { echo 'item';}?>">
<a href = "<?php the_permalink() ?>"
title = "<?php the_title();?>">
<?php echo get_the_post_thumbnail($id,
'sliderimg');?>
</a>
<div class = "carousel-caption">
<a href = "<?php the_permalink()?>"
rel = "bookmark"
title = "Permanent Link to <?php the_title_attribute();?>">
<?php the_title(); ?>
</a>
</div>
</div>
<?php
endwhile;
?>
</div>
<!-- Carousel nav -->
<a class = "left carousel-control"
data-slide = "prev"
href = "#carousel-example-generic">
<span class = "glyphicon glyphicon-chevron-left">
</span>
</a>
<a class = "right carousel-control"
data-slide = "next"
href = "#carousel-example-generic">
<span class = "glyphicon glyphicon-chevron-right">
</span>
</a>
<?php
wp_reset_query();
?>
</div>
</div>
这里是我的JS:
jQuery(document).ready(function($)
{
$('.carousel').carousel({
interval : 1000
}
)
}
);
请帮助我,如果你有任何想法。
对不起,但这里是虚拟文本只是为了这个网站让我发布我的问题!我的问题很简单明了,我不知道我应该怎么说才能发表我的问题!
你有没有打电话给普通的js文件? –
@RajKumarBhardwaj是的,我做了一切工作,如果我只是使用HTML旋转木马,所以我猜猜问题是在PHP代码。 –
让我试试我的最后,你想在上面的代码更正? –