Press "Enter" to skip to content

Get Woocommerce Shop Page featured image URL

Imagine you created a woocommerce (WordPress) website and wasted hours time to get the URL of the Shop Page Featured Image ? here this small snippet will help to print the featured image URL where you want 😉

function get_shop_featured_image() {
    if( is_shop() ) {
        $shop = get_option( 'woocommerce_shop_page_id' );
        if( has_post_thumbnail( $shop ) ) {
            $post_thumbnail_id = get_post_thumbnail_id($shop);
            $post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
            echo $post_thumbnail_url;
        }
    }
}

Cool isn’t it ? 😀 paste this code on functions.php then call the function get_shop_featured_image(); as usual wordpress function 😀

0/5 (0 Reviews)
Joel Jerushan
Joel Jerushan

A Young Full-Stack Developer from Batticaloa Sri Lanka unrestrained desire to collect new experiences with Code & World. Who Likes Spike The German Shepherd.

View all posts

    Leave a Reply