As per my question yesterday, I need to exclude all images from most of my WordPress queries – yesterday, I thought I needed to exclude them from all queries, until I came upon the following issue.
Excluding images using the following filter also excludes them from the media library, including the insert media dialog.
function remove_images($where) {
global $wpdb;
$where.=' AND '.$wpdb->posts.'.post_mime_type NOT LIKE \'image/%\'';
return $where;
}
I still want to be able to see images in my media library and insert media dialog.
Normally, I could just put in an if (!is_admin())
clause, because media library is usually seen in the admin section.
However, I also have a wp_editor
in the front end to allow my users to quickly add posts – and you can also access the media library from there.
Is there any hook or condition that I can use so that the filter isn’t included when querying the media library?