Skip to content

Instantly share code, notes, and snippets.

@SeanTOSCD
Created March 21, 2020 14:52
Show Gist options
  • Save SeanTOSCD/3d53c8096f748ac5d8e0c40678334038 to your computer and use it in GitHub Desktop.
Save SeanTOSCD/3d53c8096f748ac5d8e0c40678334038 to your computer and use it in GitHub Desktop.
Volatyl - Order download categories and tags alphabetically
<?php // DO NO COPY THIS LINE
/**
* Modify various queries
*
* @param $query
*/
function vol_custom_pre_get_posts( $query ) {
if ( is_admin() ) {
return;
}
// Order download categories and tags alphabetically
if ( $query->is_main_query() && is_tax( 'download_category' ) || is_tax( 'download_tag' ) ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'vol_custom_pre_get_posts', 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment