wp_get_attachment_url images in wrong order

Question

I have this bit of code in my xml feed and it’s picking up the images in a different order than it is in the WordPress post.

https://i.imgur.com/xmetEa6.png

Here in the admin area I can drag the images around, and the page will display the top left image first and the bottom right image last. I would like my xml feed to give the images the same order.
Thanks!

$attimages = get_attached_media('image', $post->ID);
                          $counter = 1;
                          foreach ($attimages as $image) {
                            if ($counter <= 50) {
                              echo '<image id="'.$counter.'"><url>'.wp_get_attachment_url($image->ID).'</url></image>' . "rn";
                            }
                            $counter++;
                          }
0
, , AionPhirefly 3 years 2020-03-31T04:51:21-05:00 0 Answers 114 views 0

Leave an answer

Browse
Browse