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
- How to Fix HTTP Error When Uploading Images?
- Extend Media Library
- Use REGEXP in WP_Query meta_query key
- How to show all available images in WP’s media library when using the Polylang plugin?
- Remove “Insert from URL” link in Media upload – WP 3.5
- Which filters or actions to use after a media upload and delete?
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- Change Media Uploader default directory
- How to hide media uploads by other users in the Media menu?
- Limit Media Library to Given Folder
- Changing Posts Per Page and offset with pre_get_posts
- ajax category filter
- Password protect some uploaded files, so only logged-in users can view them
- Attach Files Metabox
- WP Rest API v2 return posts with specific tag
- Append button to WordPress Image Details modal
- How to support multiple search terms query within one process?
- How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page
- How to get any tag ID
- How to disable WordPress Media resize different size version?
- Media library storing files in uploads not folders within in uploads
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- How to host different file formats/types for a media attachment without creating multiple attachments?
- What’s the point of the query_vars filter?
- Refine/Filter WP_Query Posts with jQuery or Ajax
- Use ‘parse_query’ filter to show posts that from multiple criteria
- Show selected images on top in Media Manager
- Site icons with alpha channel for self-hosted WordPress blog network
- How to apply filter inside a single wp_query?
- How to retrieve alt attribute for an attachment (uploaded image)?
- Using apply_filters(‘the_content’, $custom_query->post_content) alters output
- When to add_filter() to Custom Query
- Order by custom table and multiplication
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- Duplicate Custom Header Functionality into the post edit screen
- How to use filter hook “the_posts” with a function that refers to $this?
- query_vars filter not working even though query string parameter is present
- Site not getting correct featured image from my query
- How can I filter by slug depending on language selection
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- Uppload image from another source wp.media
- Multisite – Images often getting uploaded to the wrong month directory
- Bypass “supress_filters” in WP Query
- move_uploaded_file() not working on wordpress front end
- Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically
- How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- How to get the return value of wp.media({ frame: ‘post’ }) in all cases?
- WP_Query with different postmeta filter for each categories
- Media library only shows for admin. Doesn’t show editor or below [closed]
- Slow WP_Query with ‘OR’ on meta_query
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- Add posts to WP Query object
- Gallery shortcode numerical sorting
- How to filter a query by date in a shortcode?
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- 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?
- Migrating media files (documents only) to a fresh install and maintaining the same directory structure
- How does wordpress handle media files?
- wp.media issue with selected image
- WP_Query – How to get all posts of specific days of week by custom field date?
- 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
- Filtering by multiple conditions in the loop
- WP_Query: attachment image in “full” size?
- Custom post type – filter content by custom meta box content
- meta_query weird behaviour, static int will work, but not user data
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- Custom meta_query order for Elementor based on post meta key [closed]
- Can’t upload format files on media library
- unsharp thumbnails after uploading image
- How to Protect Uploads, if User is not Logged In?
- Media Library: Remove replace images of selected author
- WP Query filters active on wrong query
- How to upload multiple images using WP rest API to media?
- 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
- Issue generating custom filter for cpt admin columns
- Track write actions to the database
- Fetch only categorized posts
- Issues with WordPress 3.9.6 media libraries on XAMPP
- Post Type Upload Directory – {post_type}_upload_dir filter
- How to split my uploaded media into directories?
- Missing Images in Uploads Directory (Server Only)
- How can I add a Description column to the media library browser screen?
- show/hide attachments
- wordpress 3.6 media manager cropping timestamp
- Broken Media Library
- Save Custom Meta Value on Media Upload
- upload image to wordpress media library failed for custom post type
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)