Layer post title on top of image WordPress featured thumbnail image

the_post_thumbnail() does not return the path of your image. Instead, it returns the complete HTML markup for that image.

You can use this instead:

$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); echo $image[0];

If you want a specific size you can pass an additional parameter:

$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); echo $image[0];

You can either use a keyword for the size (thumbnail, medium, large or full), a size you defined with add_image_size, or pass an array with your desired size like so: array( 100, 200 )