Created
March 21, 2020 14:52
-
-
Save SeanTOSCD/3d53c8096f748ac5d8e0c40678334038 to your computer and use it in GitHub Desktop.
Volatyl - Order download categories and tags alphabetically
This file contains 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
<?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