Thanks to Milo for the pointer. I’m going to have to work on my application, but the main point is this filters the media library as required.
function only_licensed_images($query){
global $pagenow;
if( ! in_array( $pagenow, array( 'upload.php', 'admin-ajax.php' ) ) )
return;
$query->set( 'attachment_category', 'Licensed Stock Images' );
}
add_action('pre_get_posts','only_licensed_images');
Related Posts:
- How can I add an Author filter to the Media Library?
- Filter media library items by size
- Change text of Description in Image Library
- Restrict filter to run only inside specific function
- Ignore dots when searching in the media library?
- Change term name only on front
- Insert term when page is published – avoid duplicates after edits
- Filter Media by Featured on Admin
- How add a group by to the query used by the media library?
- Adaptive product filters for WooCommerce
- Create Search Form to Filter Through Terms
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- Media upload default title from file name
- How to query if meta_key does exist or not?
- How to stop the deduction in “wp_term_taxonomy” count, when the post is deleted?
- Filter causing loss of _wp_attachment_metadata
- Filter Media by attached page or blog post in Library
- How to add custom media library mime icons?
- Display post after choice two taxonomy terms
- Code restricted to dashboard, running unexpectedly in the frontend (pre_get_post and admin-ajax.php)
- How to create a list of terms who’s posts also have a predefined external term?
- This code works, but breaks the media uploader. How do I integrate it in a way that won’t?
- Is there a way to override only a portion of the function print_media_templates defined in wp-includes\media-template.php?
- Why is the change in my query not taking into account
- Insert HTML just after tag
- the_content and is_main_query
- How to Pass External Variables to Filters/Actions
- Filter by one custom field, order by another?
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Filter username field on registration for profanity and unwanted words
- At what priority does add_filter overwrite core functions?
- Add whitespace between Chinese and other letters
- How to add icons to post listing (edit.php) in admin
- Tiny MCE editor stripping xlink:href parameter from SVG USE tag
- Add quick edit fields without custom colum
- Prevent 404 when using pre_get_posts to filter an archive page
- Hook added to the_content seems to be called multiple times
- Translating an error message
- Keep Users Logged In As Long As I Like
- Is it possible to remove the filter from 4.8 text widget?
- Display WooCommerce newest product reviews on top [closed]
- Overriding wp_get_archives() apply_filters()
- How to make post and comment count unclickable with dashboard_glance_items hook
- Call to undefined function error after adding add_filter to wp-config
- How to remove X-Frame-Options: SAMEORIGIN” from WordPress?
- How can I hide all posts that don’t have a thumbnail?
- Ignore a filter on the media library
- Add Dropdown menu using “add_filter => wp_nav_menu_items”
- Filtering ‘the_title’ with option to return subhead?
- How to add a custom filter in functions.php
- Setting title using wp_title filter
- 4.0 remove_filter for WordPress core function not working for me
- How do I add a current class to the current post?
- How apply_filters work in WordPress?
- Apply a filter only once
- What functions are included in apply_filter(‘the_content’)
- Filtering admin entries for custom post type
- What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
- option_active_plugins filter not working
- How do we check if the user is logging in or registering?
- Is there a filter hook that I can use to change how taxonomy term names are displayed?
- Anonymous function is executed twice in wp_head while added from the_posts filter?
- add_filter return value
- Add a header before fields added with the attachment_fields_to_edit() filter
- Are there Limitations on filter handles?
- Hide content editor for posts after approriate date
- Why my admin doesn’t work after adding rest_prepare_post filter?
- Buddypress: Edit activity when new blog post [closed]
- How to make a button?
- How do I filter title and alt attributes in the gallery shortcode?
- Same Conditionals Not Working on Two Different Hooks
- remove_action in plugin file
- How to apply filter at search of woocommerce products?
- Filter get_template_part() $args array
- Modify a Filters Second Parameter
- Variables in post title
- Filtering post-formats from the loop using new WP-Query();
- How to edit dashboard search posts button texts for my CPT?
- How to add a filter to get_the_author_meta?
- When does a function assigned to the content_filtered_edit_pre filter hook fire?
- Capture post content before page renders
- Empty string supplied as input when parsing content
- Displaying custom taxonomy in the admin list of a custom post type
- How can I remove the kses filters when saving a specific post type ? (it breaks my JSON)
- Remove_action does not work
- page_attributes_dropdown_pages_args filter does not work
- What different ways can a plugin add a filter to a WordPress site?
- How to access plugin variables from theme templates without using globals?
- Make an array filterable per hook
- How to pass variables to custom filter from multiple functions
- WooCommerce Custom Product Validation [closed]
- Make WP not format code, not insert line breaks in between tags
- How to get a single hook from wp_head()?
- WP filter to alter admin CSS styles?
- Filter posts by meta data using custom query
- WordPress add_filter to post_date
- create a shortcode with acf including a filter
- posts_results filter – additional sort, with a meta value, to move posts to the end of the results, with pagination working
- How to use parse_query() to add an additional filter based on content to page search?
- FacetWP was unable to auto-detect the post listing : Having an issue with ACF load choices causing FacetWP error