Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 20, 2012 15:31
Show Gist options
  • Save billerickson/1647893 to your computer and use it in GitHub Desktop.
Save billerickson/1647893 to your computer and use it in GitHub Desktop.
<?php
add_action( 'pre_get_posts', 'be_blog_filters' );
/**
* Blog Filters
* If using the 'filter' rewrite endpoint, modify the blog query
*
* @since 1.0
* @param $query object
*/
function be_blog_filters( $query ) {
global $wp_the_query;
if( $query === $wp_the_query && 'comments' == get_query_var( 'filter' ) )
$query->set( 'orderby', 'comment_count' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment