Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@leurdo
Created February 27, 2018 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leurdo/8693534c6375c93418e5135330fc72b8 to your computer and use it in GitHub Desktop.
Save leurdo/8693534c6375c93418e5135330fc72b8 to your computer and use it in GitHub Desktop.
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