从循环中的数组获取值

问题描述:

Im循环播放一些帖子以获取附加到每个帖子的图库。我想收集所有只包含这些网址的数组中的所有网址。从循环中的数组获取值

<?php if ($the_query->have_posts()) { 
    while ($the_query->have_posts()) { 
     $the_query->the_post(); 
     if (get_post_gallery()) : 


        $gallery_images = get_post_gallery_images(); 

        // In each loop $gallery_images will contain a new 
        // array of urls. I would like to add these urls to collect all urls in another array. 

        ?> 
        <?php 
     endif; 
    } 
}?> 

我确定这一定很简单,但我不能弄明白。帮助赞赏。谢谢!

收集$ gallery_images数组中的所有url不会更容易吗?

$gallery_images[] = get_post_gallery_images(get_the_ID()); 

另外我相信get_post_gallery_images()需要post ID或post对象作为参数。请看这里:https://codex.wordpress.org/Function_Reference/get_post_gallery_images

+0

谢谢!成功了! – eggman

+0

不客气。 –