Created
January 2, 2012 06:49
-
-
Save wpfan/1549636 to your computer and use it in GitHub Desktop.
Order posts alphabetically using the posts_orderby hook
This file contains hidden or 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_filter('posts_orderby', 'blog_change_sort', 10, 2); | |
function blog_change_sort( $orderby, $query ) { | |
// Only modify main query | |
// On the tutorial category page | |
if( $query->is_main_query() && is_category('tutorials') ) { | |
return "post_title ASC"; | |
} | |
return $orderby; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment