Thanks to your suggestions, I enabled wp_debug and discovered flaws with my plugin. I have a filter for sorting posts by votes. I use it when the sort
URL parameter is on.
add_filter( 'posts_where', 'votes', 10, 2 );
I used to get Undefined index: sort
so I modified my function to first check if the variable is set.
function votes( $where, $query )
{
$sort = array_key_exists('sort', $query->query_vars) ? $_GET['sort'] : null;
if ( isset($sort) ) {
$where .= " AND $sort >= votes";
}
return $where;
}
This works fine but I'm not confident if it's correct. I'm wondering if there's a better method to do this.