I would suggest creating a new custom taxonomy for relations between a post and its “tracks” or grouping of track posts if you’d like
that way you can easily create a shortcode that will query all the needed tracks at once using a shortcode instead of calling your shortcode over and over and to order them you can create a custom field in track so in your query you can order by that field so it would be something like this (this assumes that you have a custom taxonomy named “post_tracks” and that all of the posts tracks were added to the same term of that taxonomy, also that you have a custom field to order you tracks named “in_order” :
function get_tracks($atts, $content = null) {
extract(shortcode_atts(array(
"post_tracks" => '',
"tracks" => '',
), $atts));
//if post_tracks relation term was passed:
if ($atts['post_tracks'] != ''){
$tracks = NEW WP_Query(array('post_type' => 'track', 'post_tracks' => $atts['post_tracks'], 'orderby' => 'meta_value', 'meta_key' => 'in_order' ));
while($tracks->have_posts()){
$tracks->the_post();
//do whatever you want with each track eg:
$out .= '<div class="track">
<h3>'.get_the_title($post->ID).'<h3>
<div class="track_inner">
<div class="track_img">'. get_the_post_thumbnail($post->ID, 'thumbnail').'</div>
<div class="track_content">'.apply_filters('the_content',get_the_content()).'<div>
</div></div>';
}
return $out;
}
//if its a single track you want:
$tracks = NEW WP_Query(array('post_type' => 'track','post__in' => array($tracks) ));
while($tracks->have_posts()){
$tracks->the_post();
//do whatever you want with each track eg:
$out .= '<div class="track">
<h3>'.get_the_title($post->ID).'<h3>
<div class="track_inner">
<div class="track_img">'. get_the_post_thumbnail($post->ID, 'thumbnail').'</div>
<div class="track_content">'.apply_filters('the_content',get_the_content()).'<div>
</div></div>';
}
return $out;
}
add_shortcode('tracks','get_tracks');
with this you can simple call your shortcode like this:
[tracks post_tracks="relation_tern_name"]
or just get your single track on at a time:
[tracks tracks="track_id"]