I’m generating a query for certain posts in ‘Trash’. I can retrieve the featured image URL, but I’m looking for a way to get the featured image file location on the server.
# generate the query
foreach ( $query as $post ) {
$thumbID = get_post_thumbnail_id( $post->ID );
$thumbObj = get_post( $thumbID );
$source_url = $thumbObj->guid;
# how do I get the string "/path/to/wordpress/media/library/thumbnail.jpg" ?
}
I can’t find any WordPress function that returns the actual featured image file location.
There is no wp function but its easy enough to make your own, e.g.
Expanding on David’s answer, this worked for me: