We understand this is annoying. But without advertising-income, we can't keep making this site awesome for you.
Please disable your adblock and script blockers to view this page. Appreciate! 🙏
Home English Articles How To Get Post Featured Image URL In WordPress

How To Get Post Featured Image URL In WordPress

How To Get Post Featured Image URL In WordPress

How To Get Post Featured Image URL In WordPress

Are you coding your website but struggled on How To Get Post Featured Image URL In WordPress ? Sometimes, as a WordPress developer of our clients or develop our own website, we wish to hook the pages, blog posts or even WooCommerce product pages featured image url for certain usage. In this situations, if you are not a coding expert or genius, you probably don’t know how to get it work. That’s why, this article is very important for people like you to get image url in WordPress.

You don’t have to worry about the coding skill, because I will show you how exactly step by step like all my previous post to help you get image url or if you are a e-commerce website using woocommerce get product thumbnail url in WordPress.

Continue reading the A-Z tutorial of get featured image url in WordPress and use it in whatever where you like.


WooCommerce Get Product thumbnail URL – Get image url in WordPress

Maybe you work on a WooCommerce website, and you like to get product thumbnail URL. You can use the image url in front end or any other purpose. It is not a difficult thing to get image url in WordPress. But it require adding some javascript code in your website in order to achieve it.

There are two way you can add javascript code into your wordpress website:

  1. Download a header & footer plugins
  2. Add it directly into your Functions.php file

Don’t know how to add javascript code ? Learn from here


Next, what is the code should be added?

// Show Product Image as a link
function display_fullimg() {
 $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); 
        echo '<a href="'.esc_url($featured_img_url).'" rel="lightbox" target="_blank">View Full Image</a><br>';
add_action( 'woocommerce_single_product_summary', 'display_fullimg', 30 );

Use the above javascript code, you can add a View Full Image text link in your single product page under product summary. Hence, you can just change to your favor html code or show it as a button or anything else in the echo.

WooCommerce Get Product thumbnail URL

echo ‘<a href=”‘.esc_url($featured_img_url).'” rel=”lightbox” target=”_blank”>View Full Image</a><br>’;

echo mean will call the html code out as a result in front end.

<a> is a simply link html code that you can use it as you like.

add_action( ‘woocommerce_single_product_summary’, ‘display_fullimg’, 30 );

This code will add the action by show the function (display_fullimg) results after the hook (woocommerce_single_product_summary)

Therefore, if you like to make something different and use this WooCommerce Get Product thumbnail URL on your favourite place, find more WooCommerce hook here

So this is the tutorial for today about How To Get Post Featured Image URL In WordPress. If you think this article help you a lot, please share this article. If you have any problem, leave a comment below. Thank You

Related tutorial:

  1. How to set Html lang attribute in WordPress
  2. How to Change WordPress Password Protected Text without Plugins Custom for Every Page
  3. How to Display Last Updated Date Posts In WordPress (Stepbystep)
  4. How to Get Custom Field Value in WordPress (Display WordPress Custom Fields)


Leave a Comment

You may also like