I have a custom post type called song and i want to query the wordpress database to return all the songs from a particular album and then sort them by track number. I have the following code
$args = array(
'post_type'=>'song',
'meta_key'=>'song_album',
'meta_value'=>'album title'
);
$query = new WP_Query($args);
this will successfully return all the songs from the album and I could switch it to this
$args = array(
'post_type'=>'song',
'meta_key'=>'song_track_number',
'order_by'=>'meta_value_num'
);
$query = new WP_Query($args);
which returns all the songs sorted by track number but not filtered by album. What I need to do I sort the results by one meta_key and order them by another but I’m only allowed one meta_key. Does anybody know how I can accomplish this?
Maybe this helps http://www.mattvarone.com/wordpress/query-multiple-meta-values/