ajax_query_attachments_args WordPress Filter Hook

The ajax_query_attachments_args hook is used to modify the arguments used in queries for attachments. This hook is called before the query is executed.

apply_filters( 'ajax_query_attachments_args', array $query ) #

Filters the arguments passed to WP_Query during an Ajax call for querying attachments.


Description

Top ↑

See also


Top ↑

Parameters

$query

(array)An array of query variables.


Top ↑

More Information

The ajax_query_attachments_args filter is used to filter the query that fetches the attachments displayed in the media library modal on the post edit screen.

The filter is used like this


add_filter( 'ajax_query_attachments_args', 'filter_function_name', 10, 1 )

Where filter_function_name() is the function WordPress should call when the query is being modified. Note that the filter function must return the query array after it is finished processing, or the query will be empty and no attachments will be shown.

filter_function_name() should be a unique function name. It cannot match any other function name already declared.


Top ↑

Source

File: wp-admin/includes/ajax-actions.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More