The search widget drop-down options display based on the ‘count’ of Listings for each taxonomy term (terms with the most listings will appear first in each drop-down).
There is no AgentPress-specific filter to change the order, but you could filter on get_terms
, like this:
add_filter( 'get_terms', 'custom_agentpress_term_sort_order', 10, 4 );
/**
* Change AgentPress to sort taxonomy by ID instead of by count.
*
* @param array $terms Array of found terms.
* @param array $taxonomies An array of taxonomies.
* @param array $args An array of get_terms() arguments.
* @param WP_Term_Query $term_query The WP_Term_Query object.
* @return array
*/
function custom_agentpress_term_sort_order( $terms, array $taxonomies, array $args, $term_query ) {
if ( is_admin() ) {
return $terms;
}
if ( in_array( 'area', $taxonomies, true ) ) {
$args['orderby'] = 'ID';
$args['order'] = 'ASC';
return $term_query->query( $args );
}
return $terms;
}
Add the code to your active theme’s functions.php
file, then replace ‘area’ with your taxonomy slug as it appears in the Listings → Register Taxonomies section.
You could repeat the second if
block for each taxonomy and specify the orderby
and order
values for each term.
-
This reply was modified 7 years, 2 months ago by Nick C.