Search for: Log In Free Support [Resolved] I want to get the featured Image URL of Blog Post Home › Forums › Support › I want to get the featured Image URL of Blog Post This topic has 3 replies, 2 voices, and was last updated 4 months ago by Elvin. Viewing 4 posts - 1 through 4 (of 4 total) Author Posts November 1, 2020 at 9:42 pm #1513995 Sunny Kumar Hey, I need to get the featured image URL of blog posts and then create a wp_head hook element with the below content… <link rel="preload" as="image" href="<image URL here" /> Can you please guide me to add this to my website? November 1, 2020 at 10:31 pm #1514023 ElvinStaff Customer Support Hi, You can get the featured image URL by using the get_the_post_thumbnail_url() core WordPress function. Reference: https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/ Try this snippet: add_action( 'wp_head', function(){ $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); echo '<link rel="preload" as="image" href="'.$featured_img_url.'"/>'; }); A wise man once said: "Have you cleared your cache?" November 1, 2020 at 11:06 pm #1514041 Sunny Kumar Thanks, the code works perfectly. I’m closing this support thread. November 1, 2020 at 11:11 pm #1514043 ElvinStaff Customer Support Glad it works for you. No problem. 🙂 A wise man once said: "Have you cleared your cache?" Author Posts Viewing 4 posts - 1 through 4 (of 4 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In