0

I'm trying to filter the attachments when the user tries to set a featured image for the current post, but this affects all the ajax_query_attachments_args hook requests, like the one in the upload.php page.

Is there any way to detect that the ajax_query_attachments_args request was triggered by the Set featured image link in the post edit page?

enter image description here

Note:

I know that the $SERVER['HTTP_REFERER'] would be useful in this case, but the post edit page has another Add Media button that uses the same ajax_query_attachments_args hook where I don't need to apply the same filters with it.

enter image description here

1
  • I tried to use the wp.media.featuredImage Javascript object to pass a custom param to the $_REQUEST object with no luck. I'm always receiving this request: $_REQUEST => ['action' => 'query-attachments', 'post_id' => '61', 'query' => [ 'post_mime_type' => 'image', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => '80', 'paged' => '1']] Aug 25, 2022 at 14:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.