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.)

1 Answer 1


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();

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 and acknowledge you have read our privacy policy.

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