Greetings.

Custom type of records has a need to get not a thumbnail, but only its name filename.jpg. I suppose that you first need to get the entire link via get_the_post_thumbnail_url and then cut off all unnecessary before output, but how to implement it with code? Or maybe there are more correct ways to get the name of the thumbnail file?

    1 answer 1

    This is how you can do it:

    $uri = get_the_post_thumbnail_url( $post_id ); // вернет http://mysite.ru/wp-content/uploads/2016/12/my-cool-picture.jpg $path = parse_url($uri, PHP_URL_PATH); // вернет /my-cool-picture.jpg $filename = substr($path, 1); // убрать первый символ