Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

TylerShaw on "How can I manually reload the Media Library with custom arguments?"

$
0
0

I'm working on a plugin that manipulates the WordPress 4.0+ Media Library.

I see that the attachments in the media library are loaded by an ajax call using the query-attachments action.

I need to programatically trigger this ajax call with my own custom arguments.

Here is a sample request that I've observed being sent to the server:

Array
(
    [action] => query-attachments
    [post_id] => 0
    [query] => Array
        (
            [orderby] => date
            [order] => DESC
            [posts_per_page] => 40
            [paged] => 2
        )

)

I would like to set the parameters myself, and then trigger this process from some custom JavaScript. Let's say, for example, when a button is clicked - change the order_by value and send the query-attachments call to the server, repopulating the page with the results.

How can I accomplish this?

Please let me know if I need to provide any more details.


Viewing all articles
Browse latest Browse all 8245

Trending Articles