<p>Sort by: <a href="https://wordpress.stackexchange.com/questions/75316/<?php echo str_replace(("?'.$_SERVER['QUERY_STRING']), '', $_SERVER['REQUEST_URI']).'/?sort=name'; ?>">Property Name</a> | <a href="https://wordpress.stackexchange.com/questions/75316/<?php echo str_replace(("?'.$_SERVER['QUERY_STRING']), '', $_SERVER['REQUEST_URI']).'/?sort=type'; ?>">Property Type</a>
<?php if($_GET['sort'] == 'name') $wp_query = new WP_Query(array( 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'listing_status', 'value' => array('Active', 'In Contract'), ), array( 'key' => 'listing_type', 'value' => 'For Sale' ) ), 'paged' => $paged, 'orderby' => 'meta_value', 'meta_key' => 'property_name', 'order' => 'ASC' )); ?>
<?php if($_GET['sort'] == 'type') $wp_query = new WP_Query(array( 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'listing_status', 'value' => array('Active', 'In Contract'), ), array( 'key' => 'listing_type', 'value' => 'For Sale' ) ), 'paged' => $paged, 'orderby' => 'meta_value', 'meta_key' => 'property_type', 'order' => 'ASC' )); ?>