Skip to content

Instantly share code, notes, and snippets.

@johnstonphilip
Created October 7, 2023 17:16
Show Gist options
  • Save johnstonphilip/219bfe589d298f55c083473c097ff71f to your computer and use it in GitHub Desktop.
Save johnstonphilip/219bfe589d298f55c083473c097ff71f to your computer and use it in GitHub Desktop.
This will make posts get queried in order by the term_order defined for the post in the term_relationships table
function my_order_posts_in_term_by_term_order( $orderby, $query ) {
global $wpdb;
return "$wpdb->term_relationships.term_order ASC";
}
add_filter( 'posts_orderby', 'my_order_posts_in_term_by_term_order', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment