You can use is_admin()
in conjunction with the admin global variable $pagenow
to make sure you’re not on either the upload or media page:
function remove_images( $where ) {
global $wpdb,
$pagenow;
if( is_admin() && in_array( $pagenow, array( 'upload.php', 'media-upload.php' ) ) {
return $where
}
$where .= " AND {$wpdb->posts}.post_mime_type NOT LIKE 'image/%'";
return $where;
}
Related Posts:
- How to fetch only media that was already attached to a post/page?
- Redirect to another page using contact form 7? [closed]
- get all images from the wordpress media library with link to the post they are associated with
- How to add HTML into error message
- How to upload 3 attachments to current post?
- WP Query Obj: Set value to be unequal | Hide media by admin
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- Too slow Image upload in WordPress Media Library as image number increases
- upload_max_filesize is set to 64 MB already but WordPress is still showing 2 MB
- Filter Custom Taxonomy Posts
- Include posts from some categories while excluding from others
- Changing the default wp_search_stopwords
- PHP error when trying to upload .mp3 files via Media Library [closed]
- Filter post query to only show direct children of category
- Get images attached to a specific page
- A link (not in the post) to download a specific PDF file
- Is it possible to add an argument to a custom function added to a filter hook?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Migrating media files (documents only) to a fresh install and maintaining the same directory structure
- Possible to hook into Media Library preview File column and use a custom image?
- How does wordpress handle media files?
- wp.media issue with selected image
- Is there a way in WordPress to convert images to WebP without a plugin?
- WordPress media upload issue could not insert attachment into the database
- Change AJAX filter from POST to GET for URL Parameters
- Using post_where filter only on main query NOT sidebard new WP_Query
- Filtering posts by archive showing all years
- Thumbnail images missing in WP media library
- WP_Query – How to get all posts of specific days of week by custom field date?
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- Multiple wp_query on archive page
- Retrieve select tag custom values from array and display them in current page with wp_query?
- How to use a dropdown to filter posts by custom field
- Remove post type filter added by the plugin in the final query
- Filtering by multiple conditions in the loop
- Open Media Uploader Link in single post or page
- Remove Media File Items From Server That Do Not Exist in Media Library
- relation OR instead of AND – Filtered term ID’s in loop
- Can’t order the query result as given posts id’s array
- Add SWF file to wordpress through custom template
- Filter causing loss of _wp_attachment_metadata
- filter posts by meta key with pagination
- Why does apply_filters behave different inside and outside a loop?
- WP_Query: attachment image in “full” size?
- What if I have a large file on the server that I want the wp library to have?
- Custom post type – filter content by custom meta box content
- Uploaded images result in a file url with full path on disk appended
- meta_query weird behaviour, static int will work, but not user data
- Filter sub-category from checkbox form
- Filter Media by attached page or blog post in Library
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- My combination of ‘post_type’ and ‘tax_query’ not working?
- Using WP-CLI “wp media import” to sync files to the media library
- Custom meta_query order for Elementor based on post meta key [closed]
- How to add a “base” filter for all posts visible to visitors on the site?
- How to add custom media library mime icons?
- Efficient way to move media folder to another folder
- WordPress append -1 to the image name
- Make inline uploader (plupload) on options page upload to a specific folder
- Can’t upload format files on media library
- unsharp thumbnails after uploading image
- Images not displaying on site or media library
- WordPress – Form does not filter the results of taxonomies
- How to restrict add media library only to images of the same post family?
- Replicate Media Galley Edit view in Add Media View
- How to Protect Uploads, if User is not Logged In?
- Front-End Upload media with category
- Query Posts | Combining multiple form inputs into query arguments to generate one filter result
- How to manually set an attachment in a post?
- Media Library: Remove replace images of selected author
- Sorting query_posts() with a complex orderby filter
- Handle image file and save it to media
- Adding attachment custom field metadata to TinyMCE tag
- WP Query filters active on wrong query
- How to upload multiple images using WP rest API to media?
- Custom category page with taxonomy filters
- Media not displaying other users uploads – WordPress 4.9.2
- Insert wp_query after the_content with plugin (filter the_content won’t work)
- Gather same custom field values in one value in a select tag with wp_query
- get term objects and post objects in query
- How to set selected attribute on option after filter query?
- Issue generating custom filter for cpt admin columns
- WP_Query doesn’t works inside loop
- Track write actions to the database
- Organising and display thousands of photos in media library
- Fetch only categorized posts
- Organizing the Media Library for Cleanup
- Custom query with post_class filter using current_post not working
- Issues with WordPress 3.9.6 media libraries on XAMPP
- Insert media while posting is not working with new wordpress update
- Add filter to Orderby Parameter using Array
- Post Type Upload Directory – {post_type}_upload_dir filter
- controlling whether upload is attached to post or not
- Filter WP_Query output before it is accessed (pre_get_posts)?
- How to split my uploaded media into directories?
- Missing Images in Uploads Directory (Server Only)
- Loop the posts between two dates selected using jquery datepicker
- query post based on comparison
- How can I add a Description column to the media library browser screen?
- show/hide attachments