Listing all custom post types using a specific term on the said term’s template page, in groups

Your code, when working, will consume sooo much resources. When implemented in this way – throught custom page template, WordPress will call for a content of that page (1 query) and after that it will call a query for each custom post type – another 4 queries. That’s a lot, really.

I would suggest you to take the advantage of pre_get_posts hook, where you can alter the query before any query is run. There you can specify what post types shold be queried. You can use something like this:

function extend_post_type( $query ) {
    if ( $query->is_archive() && isset($query->query_vars['people']) && $query->is_main_query() ) {
        $query->set( 'post_type', array( 'post', 'release', 'song', 'page') );
        $query->set( 'posts_per_page', -1 );
    }
}
add_action( 'pre_get_posts', 'extend_post_type' );

In this way, you’ll get the query full of post_types from people taxonomy. Now it’s time to loop the whole query and sortout the content by post type.

I would use something like that:

if ( have_posts() ) {
    while( have_posts() ) { the_post();
        if ( get_post_type() == 'post' ){
                $posts_html .= '<a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">' . get_the_title() . '</a>';
        }elseif( get_post_type() == 'page' ){
                $pages_html .= '<a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">' . get_the_title() . '</a>';
        }elseif( get_post_type() == 'song' ){
                $songs_html .= '<a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">' . get_the_title() . '</a>';
        }elseif( get_post_type() == 'release' ){
                $releases_html .= '<a href="'.get_permalink().'" title="'.the_title_attribute( 'echo=0' ).'">' . get_the_title() . '</a>';
        }
    }
    $term = get_term_by('slug', get_query_var( 'people' ), 'people' );
    echo '<h2>News for "'.$term->name.'"';
    echo $posts_html;
    echo '<h2>Releases for "'.$term->name.'"';
    echo $releases_html;
    echo '<h2>Songs for "'.$term->name.'"';
    echo $songs_html;
    echo '<h2>Pages for "'.$term->name.'"';
    echo $pages_html;
}

This approach uses only one query request and thus is resources friendly.

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