2

Is there a way to get attachments by user? I need a way to display all the images uploaded by a specific user. (I probably need the attachment IDs so that I can use wp_get_attachment_url to display them.)

3

Use a custom query for this.

$user_id = 1;
$the_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'author' => $user_id) );
if ( $the_query->have_posts() ) while ( $the_query->have_posts() ) : $the_query->the_post();
   the_title();
endwhile;

This will show all the attachment titles for user with user id 1. You can use get_the_ID() in the loop to get the attachment ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.