Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Move term to top
function move_term_to_top( $orderby, $query_vars, $taxonomies ) {
if ( 'my_taxonomy' === reset( $taxonomies ) ) {
$orderby = "(CASE WHEN t.name = 'My Top Term' THEN 1 ELSE t.name END)";
}
return $orderby;
}
add_filter( 'get_terms_orderby', 'move_term_to_top', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment