0

Im looping through some posts in order to get the galleries attached to each post. I would like to collect all urls in another array that will only contain these urls.

<?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;
    }
}?>

Im sure this must be simple but I cant figure it out. Help appreciated. Thank you!

1 Answer 1

1

Wouldn't be easier to collect all urls in $gallery_images array ?

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

Also i believe get_post_gallery_images() requires the post ID or post object as argument . See here : https://codex.wordpress.org/Function_Reference/get_post_gallery_images

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.