Last active
August 29, 2015 14:16
-
-
Save amielucha/922ea5d087a839d864a6 to your computer and use it in GitHub Desktop.
Sort posts archive by name.
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
function sort_archive_by_name( $query ) { | |
/* | |
* Change the 'if' condition to the taxonomy/category you want to apply the new sorting | |
*/ | |
if ( is_tax('product-category') ) { | |
$query->set( 'orderby', 'title' ); | |
$query->set( 'order', 'ASC' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'sort_archive_by_name' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment