WordPress filter hook · part of WordPress core
ajax_query_attachments_args
A WordPress core filter that 11 plugins also fire themselves, running on 73K+ sites between them.
“Filter the arguments passed to WP_Query during an AJAX call for querying attachments.”
How to use ajax_query_attachments_args
It's a filter: your callback receives the value, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'ajax_query_attachments_args', function( $query ) {
// Change $query here.
return $query;
}, 10, 1 );Argument names come from Media Library Assistant's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
11 plugins that fire ajax_query_attachments_args
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
Media Library Assistant70,000+ installs
apply_filters( 'ajax_query_attachments_args', $query )includes/class-mla-media-modal-ajax.php:833 -
Media Grid2,000+ installs
apply_filters( 'ajax_query_attachments_args', $query )wp-media-grid.php:103 -
WP Media Categories800+ installs
apply_filters( 'ajax_query_attachments_args', $query )wp-media-categories/includes/ajax.php:75 -
Email Customizer for WooCommerce200+ installs
apply_filters( 'ajax_query_attachments_args', $query )Core/Controllers/Admin/EmailTemplates.php:686 -
OVM Picture Organizer100+ installs
apply_filters( 'ajax_query_attachments_args', $query )index.php:478 -
PixMapr Lite: Interactive Image Hotspots60+ installs
apply_filters( 'ajax_query_attachments_args', $query )src/Features/Agent/Abilities.php:630 -
THRON10+ installs
apply_filters( 'ajax_query_attachments_args', $query )admin/class-thron-admin.php:651 -
White Label Megapack BrandingFewer than 10 installs
apply_filters( 'ajax_query_attachments_args', $query )include/functions/media/classes/includes/ajax.php:75 -
SmartWay SuiteFewer than 10 installs
apply_filters( 'ajax_query_attachments_args', $args )modules/media-folders/includes/class-swmd-folders.php:247 -
ModuleFest Media Library ManagerFewer than 10 installs
apply_filters( 'ajax_query_attachments_args', $args )includes/library-folders.php:69 -
FolderSharkFewer than 10 installs
apply_filters( 'ajax_query_attachments_args', $args )foldershark.php:2213
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.