WP-CLI » How to get WordPress image link from the media ID

How to get WordPress image link from the media ID

In this example, I’m using ID 14988


If you are logged in as admin, add the media ID in the website URL:

/wp-admin/upload.php?search=14983

then copy the file URL:

image 8 1024x650 - How to get WordPress image link from the media ID

SELECT guid FROM wp_posts WHERE ID=14988
image 9 - How to get WordPress image link from the media ID

wp post get 14988 --field='guid'

or

wp db query "SELECT guid FROM $(wp db tables *_posts) WHERE ID=14988" | head -n 2 | tail -1
image 10 - How to get WordPress image link from the media ID
See also  How to Reset WordPress Password from phpMyAdmin Database

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended