简体   繁体   中英

How to grab images by author / personal gallery

I've encountered a problem that I can't solve, while programming a page template for a profile page.

How can I get all of the attachment IDs from a particular author with a stated attachment type?

Something like get_attachments_from_user(userid, 'images');

And is it possible to provide a user an option to edit media but only his own?
For example: I uploaded an image, now only I can see it (or admins) and only I can edit it (or admins).

I'm trying to create a personal gallery for the users in my Website and in practice I have no idea how, in theory I do...

Try using this query for retrieve attachment of particular user

$query = new WP_Query( array('author'=> $your_author_id, 'post_type' => 'attachment', 'post_mime_type' => 'image',));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM