【问题标题】:Wordpress gallery image urls to arrayWordpress 画廊图像 url 到数组
【发布时间】:2015-05-25 07:57:15
【问题描述】:

我正在尝试从添加到帖子库的图像中获取 wordpress 上的图像 url 数组,我真的不知道我在这里做错了什么,但我认为我没有从中得到正确的数组wordpress,谁能帮我解决这个问题?

<?php  
if(have_posts()) : while(have_posts()) : the_post();

$gallery = get_post_gallery_images(the_post()); 
$i = 0;
foreach($gallery as $image)
{
    echo('<div>');
    echo('<img u="image" src="'.$image.'" alt="'.the_title().$i.'" title="'.the_title().$i.'"/>');
    echo('<img u="thumb" src="'.$image.'" alt="'.the_title().$i.'" title="'.the_title().$i.'"/>');
    echo('</div>');
    $i++;
 }
endwhile; endif; ?>
?>

【问题讨论】:

    标签: php wordpress image slider


    【解决方案1】:

    尝试在 $gallery 中使用“$post->ID”而不是“the_post”,如下所示:

    $gallery = get_post_gallery_images($post->ID);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-11
      相关资源
      最近更新 更多