How To Get The WordPress Post Thumbnail (featured Image) URL?

To get the WordPress post thumbnail (featured image) URL in PHP, you can use the get_the_post_thumbnail_url() function. Here is an example:

<?php
// Get the current post thumbnail URL
$thumbnail_url = get_the_post_thumbnail_url();

// Output the URL
echo $thumbnail_url;
?>

If you want to get the thumbnail URL for a specific post, you can pass the post ID as a parameter to the get_the_post_thumbnail_url() function like this:

<?php
// Get the thumbnail URL for a specific post
$thumbnail_url = get_the_post_thumbnail_url( $post_id );

// Output the URL
echo $thumbnail_url;
?>

Replace $post_id with the ID of the specific post you want to retrieve the thumbnail URL for.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!