Last active
August 29, 2015 13:57
-
-
Save bohman/9526448 to your computer and use it in GitHub Desktop.
example on how to modify queries with filters in wordpress
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
//--------------------------------- | |
// Modify these taxonomy pages to show all posts | |
// and sort them alphabetically | |
//--------------------------------- | |
add_filter('posts_orderby', 'mashcat_alphabetical'); | |
add_filter('post_limits', 'mashcat_limits'); | |
function mashcat_alphabetical($orderby) { | |
if(!is_admin() && (is_tax('foreign-apis') || is_tax('api-tags') || is_tax('mashup-tags'))) { | |
return 'post_title ASC'; | |
} | |
return $orderby; | |
} | |
function mashcat_limits($limits) { | |
if(!is_admin() && (is_tax('foreign-apis') || is_tax('api-tags') || is_tax('mashup-tags'))) { | |
return ""; | |
} | |
return $limits; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment