Created
January 30, 2015 14:30
-
-
Save blainerobison/16220392bdd29d8ee634 to your computer and use it in GitHub Desktop.
wp: Order get_terms() Numerically [WordPress]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Order get_terms() by number | |
* | |
* @param string $orderby ORDERBY clause of the terms query. | |
* @param array $args An array of terms query arguments. | |
* @param string|array $taxonomies A taxonomy or array of taxonomies. | |
* @return string | |
*/ | |
function prefix_get_terms_orderby_numeric( $orderby, $args, $taxonomies ) { | |
// cast term name as number | |
if ( in_array( 'numeric', $args ) ) | |
$orderby = 't.name * 1'; | |
return $orderby; | |
} | |
add_filter( 'get_terms_orderby', 'prefix_get_terms_orderby_numeric', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment