Title: Search Widget dropdown display issue
Last modified: March 13, 2017

---

# Search Widget dropdown display issue

 *  [Lisa Cerezo](https://wordpress.org/support/users/lisathirdsideco/)
 * (@lisathirdsideco)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/search-widget-dropdown-display-issue/)
 * I’m using AgentPress for a client’s real estate site, but the dropdown options
   in the search widget aren’t sorting correctly. On the Office page, the office
   rent taxonomies were registered in order from smallest amount to largest, but
   they don’t display that way. According to my understanding, the search widget
   should sort by ID from smallest number to largest. Any idea why it isn’t doing
   that?
 * [http://1-main.com/propertytype/office/](http://1-main.com/propertytype/office/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [withacause](https://wordpress.org/support/users/withacause/)
 * (@withacause)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/search-widget-dropdown-display-issue/#post-9473210)
 * I am also having this issue. I downloaded the Taxonomies Reorder plugin, but 
   actually it is not the taxonomies, it is the dropdown items of each taxonomy 
   that are in the wrong order. So that plugin doesn’t help. Any ideas from anyone
   out there?
 *  Plugin Support [Nick C](https://wordpress.org/support/users/modernnerd/)
 * (@modernnerd)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/search-widget-dropdown-display-issue/#post-9477424)
 * The search widget drop-down options display based on the [‘count’](https://github.com/copyblogger/agentpress-listings/blob/772a30dee459dbc0cccba9daf098662dd947532a/includes/class-property-search-widget.php#L40)
   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 8 years, 8 months ago by [Nick C](https://wordpress.org/support/users/modernnerd/).
 *  [withacause](https://wordpress.org/support/users/withacause/)
 * (@withacause)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/search-widget-dropdown-display-issue/#post-9480718)
 * Thank you so much, Nick Cernis, you are brilliant. This worked perfectly.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Search Widget dropdown display issue’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/agentpress-listings_46515d.svg)
 * [AgentPress Listings](https://wordpress.org/plugins/agentpress-listings/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/agentpress-listings/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/agentpress-listings/)
 * [Active Topics](https://wordpress.org/support/plugin/agentpress-listings/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/agentpress-listings/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/agentpress-listings/reviews/)

## Tags

 * [AgentPress](https://wordpress.org/support/topic-tag/agentpress/)
 * [taxonomies](https://wordpress.org/support/topic-tag/taxonomies/)

 * 3 replies
 * 3 participants
 * Last reply from: [withacause](https://wordpress.org/support/users/withacause/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/search-widget-dropdown-display-issue/#post-9480718)
 * Status: not resolved