我正在为一个网站制作一个滑块,图片来自 WP 帖子的画廊,效果很好。但我想要那里的图像信息,例如图像的标题和描述。这是我当前的代码和我的滑块的循环,它完美地工作。
函数.php:
<?php function aldenta_get_images($size = 'thumbnail') {
global $post;
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
$results = array();
if ($photos) {
foreach ($photos as $photo) {
// get the correct image html for the selected size
$results[] = wp_get_attachment_image($photo->ID, $size);
}
}
return $results;
} ?>
页:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="banner">
<ul class="rslides">
<?php $galleryimages = aldenta_get_images('medium');
foreach ($galleryimages as $galleryimage ) { ?>
<li>
<?php echo $galleryimage; ?>
<div class="slider-desc">
<div class="slider-desc-text">
<div class="slider-desc-title"><h1></h1></div>
<div class="slider-desc-content"><?php ?></div>
<div class="slider-link"><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/slider-arrow.png"></a></div>
</div>
</div>
<?php } ?>
</li>
<?php endwhile; else: ?>
<?php endif; ?>
</ul>
我只希望图像信息显示在图像上,您可以看到我没有当前功能,只需将该信息放入循环中以显示每张幻灯片。