Last active
December 22, 2015 02:18
-
-
Save robneu/6402258 to your computer and use it in GitHub Desktop.
Use pre_get_posts to change the ordering of category posts to the title.
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 | |
add_action( 'pre_get_posts', 'prefix_change_category_order' ); | |
/** | |
* Customize category Query using pre_get_posts. | |
* | |
* @author FAT Media <http://youneedfat.com> | |
* @copyright Copyright (c) 2013, FAT Media, LLC | |
* @license GPL-2.0+ | |
* @todo Change prefix to theme or plugin prefix. | |
* | |
*/ | |
function prefix_change_category_order( $query ) { | |
if ( $query->is_main_query() && ! $query->is_feed() && ! is_admin() && is_category() ) { | |
$query->set( 'orderby', 'title' ); | |
$query->set( 'order', 'DESC' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment