Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created February 28, 2021 20:35
Show Gist options
  • Save tripflex/b2cbf8b2c7a35d7736e048865276b2b3 to your computer and use it in GitHub Desktop.
Save tripflex/b2cbf8b2c7a35d7736e048865276b2b3 to your computer and use it in GitHub Desktop.
Remove Taxonomy Ordering when using WP Job Manager Search and Filtering (native ordering)
<?php
add_filter( 'search_and_filtering_get_taxonomy_data_options_args', 'smyles_sf_remove_tax_ordering' );
function smyles_sf_remove_tax_ordering( $args ){
if( isset( $args['order'] ) ){
unset( $args['order'] );
}
if ( isset( $args['orderby'] ) ) {
unset( $args['orderby'] );
}
return $args;
}
@tripflex
Copy link
Author

This snippet basically allows the ordering to be handled by the main get_terms() function, which can be handled by something like this plugin:
https://wordpress.org/plugins/simple-taxonomy-ordering/

This filter can also be used just to set your own custom ones.

Here's how the filter is called:

		$args = apply_filters( 'search_and_filtering_get_taxonomy_data_options_args', array(
			'taxonomy' => $taxonomy,
			'hide_empty' => false,
			'order'   => 'ASC',
			'orderby' => 'name',
			'value_field' => $is_slug_taxonomy ? 'slug' : 'term_id',
		));

@tripflex
Copy link
Author

tripflex commented Mar 2, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment