First of all don’t use query_posts
function, use the WP_Query class instead.
Secondary you forget to fetch attachments for a post. You can get attachments list by calling get_children
function.
$args = array (
'post_type' => 'attachment',
'post_mime_type' => 'audio',
'numberposts' => -1,
);
$the_query = new WP_Query( 'portfolio-tags=apple&post_type=portfolio&posts_per_page=-1&orderby=title&order=asc' );
if ( $the_query->have_posts() ) :
echo '<ul>';
while ( $the_query->have_posts() ) :
$the_query->the_post();
$images =& get_children( 'post_type=attachment&post_mime_type=image' ); ?>
<li>
<span><?php echo the_title();?></span>
<?php foreach ( $images as $attachment_id => $attachment ) : ?>
<span><a href="https://wordpress.stackexchange.com/questions/55226/<?php echo get_attachment_url( $attachment_id );?>" target="_blank">Demo</a></td>
<?php endforeach; ?>
</li>
<?php endwhile;
echo '</ul>';
endif;
wp_reset_postdata();