Created
June 7, 2019 12:40
-
-
Save maxyudin/80523f59b260f85d2f4aae33f6281905 to your computer and use it in GitHub Desktop.
[WordPress] Redefine get_terms() default arguments
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
// https://wordpress.stackexchange.com/questions/339849/how-to-list-categories-in-reverse-alphabetical-order/339853#339853 | |
add_filter( 'get_terms_args', 'mxd_term_args', 10, 2 ); | |
function mxd_term_args( $args, $taxonomies ) { | |
// don't affect admin area | |
if ( is_admin() ) { | |
return $args; | |
} | |
// redefine default arguments for 'category' taxonomy ONLY | |
if( in_array( 'category', $taxonomies )) { | |
$args['orderby'] = 'name'; | |
$args['order'] = 'DESC'; | |
$args['hide_empty'] = false; | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment