This little code snippet can be used to get ID of a Tumblr post if you have URL of post, no matter if there is unique slug at the end ( or not (, or if it’s on custom domain (

Can be useful when you have to deal with Tumblr API.

$full_url = '';
$path = parse_url( $full_url, PHP_URL_PATH );
$path_components = explode( '/', trim( $path, '/' ) );
$tumblr_post_id = $path_components[1];