get_children returns older images

Your problem is here:

        'order' => 'ASC',
        'numberposts' => '-1',
        'orderby' => 'menu_order ID'));

You asked for them to be ordered by menu order, then ID. Then you asked for them to be given in ascending order.

Since newer posts have higher IDs than older posts, older posts get shown first. Flip the ASC to DESC and you’ll likely get what you wanted.

Other notes:

  • Never use query_posts, there is no valid usage of this function that can’t be accomplished with WP_Query or the pre_get_posts filter #bestpractice #headache #eldritchhorrors #unforgivablesins
  • Don’t bother with all the helper methods for grabbing posts, such as get_pages, get_children, etc, they’re all wrappers of WP_Query that add extra complications. You already pass the parent ID anyway #bestpractice
  • Always have an if ( have_posts() ) { check, if no posts were found you’d be told nothing, left wondering what went wrong #debugging
  • Don’t use -1, set a super high number, but never set unlimited. Even if you never expect to reach that number, set it anyway. Pagination has performance benefits too, and your server can only hold so much in memory and hold has so much time to generate the page before it reaches the execution time limit #performance #scaling #hightraffic
  • escape your output, don’t do echo $url, do echo esc_url( $url ), this guarantees that it is indeed a URL, and that nothing malicious got snook in by a hacker #security