How to get a WordPress Media (attachment) ID
There are several ways to go about getting the attachment ID (of the ‘attachment’ WordPress post type, stored in the wp_posts WPDB [Wordpress DataBase] table. Here are some of them:
From the Media Library:
Navigate to Dashboard -> Media. Here you will see your WordPress uploads (Media), either in grid view or list view. They’re both fine, it’s just a preference thing. Instructions for both are below.
List View
If in List view, navigate to the item by scrolling or using the search bar at the top right. Then hover over the title of that file, like so:
Grid View
In grid view, it’s a little bit different. You’ve got to click on the media file. A popup window will open up. Take a look in your browser URL bar and you will see the attachment ID there, after where it says “?item=” Like this:
(advertisement)