For the media library you can use the pre_get_posts hook targeting upload.php by means of $pagenow, a global variable, or even better, because globals are the devils child, by means of get_current_screen(). I’m assuming you want to target the media modal tab too – because targeting only one, but not the other, doesn’t make much sense after all -, you can do that via the ajax_query_attachments_args hook.
Related Posts:
- What is the action hook for save media-form on gallery tab?
- Add media library tab
- How can I modify the code generated for a PDF by the Add Media button in Classic Editor?
- How to filter the URL of thumbnail size in the Media Grid and admin pages
- How to get WordPress’ hooks/actions run sequence?
- Is there a hook that runs after a user logs in?
- WP Cron Doesn’t Execute When Time Elapses
- Why do some hooks not work inside class context?
- Action hook for custom tax edit
- Is there a limit to hook priority?
- Auto-retrieve YouTube Image for Thumbnail?
- Hook into WordPress update?
- Do WordPress Core Filenames Work as Hooks?
- Adding function directly vs using hook in function.php
- How to check if which hook triggered the call to a function?
- How can I send to multiple Contact Form 7 recipients based on form input? [closed]
- How do I flush the rules after saving settings using the Settings API?
- Run javascript code after wp_login hook?
- Is it possible to save/modify a post without calling the “save_post” action hook?
- Redirect logged in users if they are on a specific page
- Generating robots.txt dynamically
- Hooks are not executing
- Rest API Hook When Post Is Requested
- Best possible way to get all options
- wordpress custom modules/widget areas on the page? can i make my own?
- How to add hook to the_title() and get_the_title()
- Add custom URLs to WordPress’s XML sitemap
- Hooking after get_header()
- How to get post ID in post_updated action hook?
- How can I set status=’publish’ for all featured images?
- How to send data from a form created by a plugin to an external API?
- How to get all functions with priority ‘1’ attached to hook ‘wp_head’
- How to change the location of admin notice in html without using Javascript?
- Why doesn’t wp_enqueue_script() work when including a JavaScript file with TEMPLATEPATH?
- How to find hooks as per Just-In-Time approach?
- WordPress action and filter hooks runs asynchronously?
- Prevent attachment from being deleted
- how to determine how many and what kind of arguments are passed to hooks
- Update post meta using pending_to_publish hook
- Get log of function/method calls made by do_action() on WordPress initialization
- Is it possible to change image urls by hooks?
- Append a code when at the current page in wp_list_pages()
- User update hook
- register_activation_hook not updating
- Redirect customer to login if not logged in when proceeding to checkout
- PHP header() gives headers already sent
- How to replace a function using a child theme?
- WP_query hooks before execute a search query
- Conditional for autosave or auto draft?
- Using delete_attachment to prevent an attachment not working
- How does do_action( ) works actually?
- Giving the_excerpt in the place of the_content?
- Hook to init or call explicitly within functions.php
- How to add content to the end of a page with a hook?
- WordPress’s “Text” Format
- How to use a WooCommerce action hook?
- run script on publish
- Calling add_action on a filter hook?
- Remove Header and Footer if user is not logged on
- What is deprecated_argument_run meant to do exactly?
- How do I run an action after a featured image has been selected in the Gutenberg editor?
- How to run a function after wp() in the wp-blog-header.php file?
- WordPress cronjob get scheduled but function does not run
- How to add a HTML element in ADMIN edit post window?
- wp query add array by if condition
- Gravity Forms | Form Object is NULL [closed]
- Change status of page after an event (Looking for best practice advice)
- Post via wp-admin and via iOS app, same hooks and triggers involved?
- Add action save post when create and publish
- Hooking after blog info update
- Hook to add_action(‘updated_option_my_option’, [$this, ‘save_data’], 10, 3]);
- Hooks for Start/End of Batch Plugin Updates in wordpress
- How to load another post if condition is true
- Registered custom dynamic tag not appearing
- Struggling with plugin dev basics: add_action
- RTrouble passing arguments to action
- How to hook add_action() into after category description with id?
- delete_user hook failed
- Which things should be called with `after_setup_theme`?
- Changing header logo href for the checkout page
- Prefixing widget_posts_args Hook
- Can’t get ID of post that relates to the comment
- Updating user meta data from external link, user not logged in
- Remove lines from RSS Feed
- Is there a hook that triggers when grant secondary user role in WordPress?
- How can I insert custom html code inside a div dynamically?
- How WordPress understands what do with the (all) key in the $wp_filter array? [duplicate]
- WP-Automatic to run publish hooks
- template_redirect and title
- Plugin hook breaks new WP 4.0 media library grid view?
- Hide post completely and still reach it via cURL
- How do I remove an action hook by s2member
- Problem in register activation hook and Copying folder
- Why does hook priority affects admin menu permission error?
- add_action failed to display function by a plugin
- How can I get the ID before after_setup_theme?
- Hook on opening a media/document
- Why does before_delete_post run when opening a post in the backend?
- ‘At a Glance’ dashboard: combining infos
- Getting fatal error when using manage_media_columns filter of WordPress