我在页面中有一个图像滑块我希望通过单个帖子放置图像,wordpress提供get_post_gallery函数以通过单个帖子获取图像,此阶段已完成但是 问题是它显示缩略图图像我想在滑块上显示完整图像, 就像我们在特色图像场景中一样。 $ img = wp_get_attachment_image_src(get_post_thumbnail_id($ post-> ID),' tasty-thumb'); 这是我在模板中的代码:
<?php
query_posts('category_name=tandem-slider');
while ( have_posts() ) : the_post();
if ( get_post_gallery() ) :
$gallery = get_post_gallery( get_the_ID(), false );
/* Loop through all the image and output them one by one */
foreach( $gallery['src'] AS $src )
{
?>
<div class="jump_slider_single">
<img src="<?php echo $src; ?>" alt="" class="img-responsive">
<article>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt.</article>
<span class="double_shad"></span>
</div><!--jump_slider_single-->
<?php
}
endif;
endwhile;
?>
我想根据我在function.php
中给出的图像大小来获取图像 if ( function_exists( 'add_image_size' ) ) {
add_image_size(&#39; gallery-image&#39;,1350,500,true); }
我是如何做到这一点我感到困惑
答案 0 :(得分:0)
试试这个: -
$gallery = get_post_gallery( get_the_ID(), false );
$ids = explode( ",", $gallery['ids'] );
foreach( $ids as $id ) {
$link = wp_get_attachment_url( $id );
$image_list . = '<li>' . $link . '</li>';
}