我循环浏览一些帖子,以便将每个帖子附加到画廊。我想收集另一个只包含这些网址的数组中的所有网址。
<?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;
}
}?>
我确定这一定很简单,但我无法弄明白。帮助赞赏。谢谢!
答案 0 :(得分:1)
收集$ gallery_images数组中的所有网址会不会更容易?
$gallery_images[] = get_post_gallery_images(get_the_ID());
另外我相信get_post_gallery_images()需要帖子ID或帖子对象作为参数。见这里:https://codex.wordpress.org/Function_Reference/get_post_gallery_images