Order an archive page for a post category by a numeric custom field
<?php
/*Custom sort cateogry id 5 archive */
function isg_custom_property_archive( $query ) {
// only modify queries for category 5 if it exists
if ( !is_admin() && term_exists(5,'category') && $query->is_category(5)) {
$query->set('posts_per_page','-1');
$query->set('offset','0');
$query->set('orderby', 'meta_value_num');
$query->set('meta_key', 'price');
$query->set('order', 'DESC');
}
}
add_filter( 'pre_get_posts', 'isg_custom_property_archive' );