There may be a simpler way, but I am certain that it can be done using the technique shown in this code.
You will need to register three filters:
add_filter('posts_fields','mam_posts_fields');
add_filter('posts_join','mam_posts_join');
add_filter('posts_orderby','mam_posts_orderby');
$paged = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;
Then, set up the values for the filters to add to the query:
$mam_global_fields = 'intval(wpmeta.meta_value) as sortval';
$mam_global_join = "LEFT JOIN $wpdb->postmeta wpmeta ON
({$wpdb->posts}.ID = wpmeta.post_id AND wpmeta.meta_key = 'priority')";
$mam_global_orderby = 'sortval';
query_posts("paged=$paged")
And, either in functions.php or at the end of your template, define the filters:
<?php function mam_posts_fields ($fields) {
global $mam_global_fields;
return "$fields, $mam_global_fields";
}
function mam_posts_join ($join) {
global $mam_global_join;
return "$join $mam_global_join";
}
function mam_posts_orderby ($orderby) {
global $mam_global_orderby;
return "$mam_global_orderby, $orderby";
}?>