Joel Jerushan / Web Developer from Batticaloa Sri Lanka

Call +94766881010, Email boomerang@joel.lk

Get Woocommerce Shop Page featured image URL

Posted on: June 8th, 2017 by Joel Jerushan

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 😀

Tags: , , , , , , , , , , , , , ,