Skip to content

Instantly share code, notes, and snippets.

@bohman
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bohman/9526448 to your computer and use it in GitHub Desktop.
Save bohman/9526448 to your computer and use it in GitHub Desktop.
example on how to modify queries with filters in wordpress
//---------------------------------
// 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