【发布时间】:2017-05-12 02:19:11
【问题描述】:
<?php $loop = new WP_Query( array( 'post_type' => 'gallery',
'posts_per_page' => 100 )
);
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if ( get_post_gallery() ) :
/* Loop through all the image and output them one by one */
foreach( $gallery['src'] as $src ) : ?>
<img src="<?php echo $src; ?>" class="my-custom-class" alt="Gallery image" />
<?php
endforeach;
endif;
endwhile; wp_reset_query(); ?>
上面的代码从名为“gallery”的自定义帖子中提取了一个 WordPress 画廊。然后它存储并显示图像。有没有办法将画廊的标题也存储到变量中?
【问题讨论】: