سؤال

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',));

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top