how to display custom taxonomy on an archive page?

I’m only going to focus on the category listing you have in the code above and ignore the custom query since that’s not what you’re asking about.

<?php
// I assume the custom taxonomy slug is "basics"
$categories = get_the_terms( get_the_ID(), 'basics' );

// get_the_terms returns false, a wp error, or an array of term objects.
if ( $categories && ! is_wp_error( $categories ) ) {

    foreach ( $categories as $category ) {
        // get_term_link requires taxonomy slug as the second parameter.
        echo '<a href="' . esc_url( get_term_link( $category->term_id, 'basics' ) ) . '" title="' . sprintf( esc_html__( 'View all posts in %s' ), esc_html( $category->name ) ) . '">' . esc_html( $category->name ) . '</a> ';
    }
}
?>

I adjusted a few details. Inline comments should provide some detail. I also added escaping to the output since this is a best-practice.

tech