Commit 6c19f5ec authored by John James Jacoby's avatar John James Jacoby
Browse files

Only filter main queries, and suppress filters to avoid stomping JOIN's.

parent 90ec7300
......@@ -73,7 +73,7 @@ function wp_media_categories_get_media_category_options( $selected_value = '' )
function wp_media_categories_no_category_request( $query_args = array() ) {
// Bail if not in admin
if ( ! is_admin() ) {
if ( ! is_admin() || ! is_main_query() ) {
return $query_args;
}
......@@ -85,6 +85,12 @@ function wp_media_categories_no_category_request( $query_args = array() ) {
// No categories, so do a "NOT EXISTS" taxonomy query
if ( 'no_category' === $query_args[ $media_category ] ) {
// This is necessary to prevent the JOIN clause from being stomped
// and replaced for postmeta
$query_args['suppress_filters'] = true;
// This adds a taxonomy query, looking for no terms
$query_args['tax_query'] = array(
array(
'taxonomy' => $media_category,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment