how to display all images from their siblings/ from same parent?

Nice to see Liverpool at the top there!

I’d go about this using a page template. Given that as far as I’m aware we only know the page names I’ll add it in that way.

The process is this:

  1. Loop through top level pages
  2. Collect child pages as array
  3. Loop through child pages
  4. Loop through child attachments

    <?php
    
    /*
    Template Name: All images
    */
    
    get_header();
    
    // pages to loop through
    $sports = array( 'Hockey', 'Football' );
    
    // empty array where we collect teams
    $teams = array();
    
    // collect teams
    foreach( $sports as $sport ) {
    
        $page = get_page_by_title( $sport );
    
        $teams = array_merge(
                    get_children( array(
                        'post_parent' => $page->ID,
                        'numberposts' => -1,
                        'post_type' => 'page'
                    ) ),
                    $teams
                );
    
    }
    
    // you could do some custom sorting or randomisation of the order here
    
    // loop through teams
    foreach( $teams as &$team ) {
    
        // get image attachments for each team
        $images = get_children( array(
                'post_parent' => $team->ID,
                'numberposts' => -1,
                'post_type' => 'attachment',
                'post_mime_type' => 'image'
                ) );
    
        // output images
        foreach( $image as &$image ) {
    
            // link to team page
            echo '<a href="' . get_permalink( $team->ID ) . '">';
            echo wp_get_attachment_image( $image->ID, 'medium' );
            echo '</a>';
    
        }
    
    }
    
    get_sidebar();
    
    get_footer();
    

You’ll want to modify the markup a bit and bear in mind this will be quite slow so you may want to consider a caching plugin.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)