我正在尝试创建一个div,其中包含特色图片的标题出现在滑块的中间。
为什么字幕循环?
link:http://natashamcdiarmid.com/clients/JLP/wp/
它的外观:http://natashamcdiarmid.com/clients/JLP/
<div class="slider">
<?php query_posts( 'post_type=page' ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_post_thumbnail('slider'); ?>
<div class="caption-wrap"><?php the_post_thumbnail_caption(); ?></div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
答案 0 :(得分:0)
我从未看到此功能the_post_thumbnail_caption();
,因此请按get_post( get_post_thumbnail_id() )->post_excerpt
<div class="slider">
<?php query_posts( 'post_type=page' ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_post_thumbnail('slider'); ?>
<div class="caption-wrap"><?php echo get_post( get_post_thumbnail_id() )->post_excerpt ?></div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
答案 1 :(得分:0)
Ok I figured it out:
<div class="slider">
<?php query_posts( 'post_type=page&page_id=48' ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_post_thumbnail('slider');
echo '<div class="caption-wrap">' . get_post(get_post_thumbnail_id())->post_excerpt . '</div>'
; ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>