i assume its exclusive to either sort by title $_GET['sort_title']
OR sort by custom field ( but not necessarily) and you that you pass $_GET['sort_price']
. if neither are present, “title” is default.
with that in mind, check both values
if( isset($_GET['sort_title']) ) {
$sort_by = $_GET['sort_title'];
//orderby can accept multiple values
}
elseif ( isset($_GET['sort_price']) ) {
$sort_by = 'meta_value';
$args["meta_key"] = 'price';
}
else { $sort_by = "title";
if so, don’t forget to change your query to allow for restrictions on other custom fields.
args['meta_query'] = array(
array(
'key' => 'Community',
'value' => '$community_choice'
)
)
meaning: i’m giving top priority to “title”. then if not provided, check for “price” finally, if neither are set, the default is title