A solution that works for me is to add a clause to the WordPress query when the media library is being displayed.
From browsing my WordPress database I noticed that the full path to wp_posts.post_type="attachment"
is stored in the wp_posts.guid
column.
add_filter('posts_where', 'limitMediaLibraryItems_56456', 10, 2 );
function limitMediaLibraryItems_56456($where, &$wp_query) {
global $pagenow, $wpdb;
// Do not modify $where for non-media library requests
if ($pagenow !== 'media-upload.php') {
return $where;
}
$where .= " AND {$wpdb->posts}.guid LIKE '%my-path-segment%'";
return $where;
}
Related Posts:
- Hide upload image fields for the different media upload popups
- I’m using add_meta_box() but want to include TinyMCE editor *and* Media Uploads for each box
- WordPress media uploader – upload tabs not hiding
- problem in uploading attachment to custom directory
- Redirect to another page using contact form 7? [closed]
- Can’t upload format files on media library
- Altered Media Library URLs
- How can I add a Description column to the media library browser screen?
- Modify existing plugin function using filter (without modifying the plugin directly)
- Rename UPLOADS folder with custom WP_CONTENT_DIR
- How to move wp-content (or uploads) outside of the WordPress directory
- Add more rows on media picker
- What is the proper way to apply the login_form_bottom filter?
- How to filter get_avatar?
- Ignore a filter on the media library
- Automatically wrap post image in div
- How-to inspect filter-able $vars?
- How to exclude certain widget from showing up on home/front page? [duplicate]
- media_handle_upload weird thing
- Looking to display non-image files in Gallery with logo specific to file type
- Custom Queries – Child Categories not showing up
- Custom search page and search by title, content and tag
- Customizing the default logout page of WordPress
- Is there a filter hook that I can use to change how taxonomy term names are displayed?
- How do I go straight to “Edit More Details” when clicking on an item in the media library?
- Syncing Avatars across multisite
- How to re-arrange media uploaded using : media_handle_upload() as per year / month
- Changing image URLs in media library
- How to retrieve alt attribute for an attachment (uploaded image)?
- How to insert a sitemap within a subsite when using WordPress multisite
- Add options to the “Screen Options” section on the “Menus” editor
- Add a InfoBox in the media upload window
- woocommerce_checkout_fields modifying existing billing_phone label created new field
- How to add an extra variable to login and authenticate it?
- changing font size and font of a custom message added after comment
- result from custom filter admin table list backend does not work
- custom upload directory only for plugin uploads
- Can I create my own custom Attachment Display Setting?
- Admin search post meta
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- Installing new theme on running site
- Combine two conditions in one statement syntax [closed]
- More Fields & Media Upload
- Possible to hook into Media Library preview File column and use a custom image?
- Get users based on month ACF datepicker field
- Dynamically Filtering Posts by Data Points – Any Pointers?
- How to allow .bin files upload?
- How to append custom text to the output of ‘categories widget’?
- Media Upload not working after hiding some elements from functions.php
- Filter causing loss of _wp_attachment_metadata
- How to Add Additional Search Button?
- Custom Register Link on Backend Form
- Personalized Gallery what are my options?
- Filter Media by attached page or blog post in Library
- How to make WordPress search page use a relative path
- Adding overlay search to wordpress using add action/filter
- How to add HTML into error message
- How to get the full product name by ignoring custom modification on it
- Moving Quantity after product description
- the temporary save folder is wrong
- Wrap WordPress Login Form in custom Div
- How to fix custom add menu page preventing media library from loading
- Post filter with multiple checkbox taxonomy terms
- How to append the excerpt to the content in the single post page?
- How do I enable the text editer in my WordPress theme? [closed]
- Show different pages on site depending on user choice
- Is there a way to limit multi upload in media upload box?
- Organizing the Media Library for Cleanup
- Custom display for homepage, tag and author pages
- Custom Link In WordPress Media “Attachment Details” Upload Screen
- Pre_Get_Posts order DESC not registering
- Apply `the_content’ filter to theme customisation live preview
- How can I create more “create attachment” custom field – any idea?
- Upload files in wordpress
- Custom image sizes ignored in WP 3.5
- WordPress uploads directory. Featured Images storage
- Add variable : 1 Week ago
- How to add filters to my site?
- New WP_Customize API – how does it work under the hood?
- how to override woocommerce specific loop or archive-product.php [closed]
- Enabling Sessions in WordPress 3.0
- Search through custom post type and custom fields takes 5 minutes
- How to store foreign language characters in WordPress? [closed]
- Is it possible to replace PHP with NodeJS?
- Change separators in HTML tags
- Cannot figure out how to center div in WordPress theme [closed]
- WordPress sort search results by custom order
- Adding posts to custom menu [closed]
- 404 (category, pages, archives) when using custom rewrite rules
- WordPress : using AJAX to get posts & Sidebar Content to an external application
- How to edit alternate inactive themes in “Appearance -> Customise” screen?
- Custom Same Page Search
- How to upload large media file in chunks, without any plugin?
- Make inline uploader (plupload) on options page upload to a specific folder
- wp.blocks.registerBlockType not showing what I want on the frontend
- How to add the option to choose between sizes for featured image within post editor?
- Adding images to anchors in the list created and fetched with wp_nav_menu
- Secondary loop doesn’t work
- Adding pages to the Admin panel
- What capability is required to view posts, scheduled in the future, by someone else?