1 回答

TA貢獻(xiàn)1848條經(jīng)驗 獲得超2個贊
經(jīng)過大量搜索,我找到了這個解決方案,它對我來說效果很好:
<div id="slideShow" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'published',
'cat' => '4',
'showposts' => '10',
);
$my_query = new WP_Query($args);
while ($my_query->have_posts()) :
$my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<div class="carousel-item active">
<?php if (has_post_thumbnail($post->ID)) : ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'carousel'); ?>
<img src="<?php echo $image[0]; ?>" class="slideShowImage d-block mx-auto" alt="Los Angeles" width="1100" height="500">
<?php endif; ?>
<div class="carousel-caption">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>
</div>
- 1 回答
- 0 關(guān)注
- 107 瀏覽
添加回答
舉報